ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-12-29 22:15:04
Exec Total Coverage
Lines: 9654 13369 72.2%
Functions: 115 142 81.0%
Branches: 7510 12865 58.4%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "base/misctypes.h"
45 #include "base/initdata.h"
46
47 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
48 extern void setZScriptVersion(int32_t s_version);
49
50 static bool read_ext_zinfo = false, read_zinfo = false;
51 static bool loadquest_report = false;
52 static char const* loading_qst_name = NULL;
53 static std::string last_loaded_qstpath;
54 static byte loading_qst_num = 0;
55 static byte subscr_mode = ssdtMAX;
56 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
57 // what combos were used. This vector just lets us convert those old quests on load.
58 static std::vector<byte> old_combo_pages;
59
60 dword loading_tileset_flags = 0;
61
62 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
63 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
64
65 #ifdef _MSC_VER
66 #define strncasecmp _strnicmp
67 #endif
68
69 #ifndef _AL_MALLOC
70 #define _AL_MALLOC(a) _al_malloc(a)
71 #define _AL_FREE(a) _al_free(a)
72 #endif
73
74 using std::string;
75 using std::pair;
76
77 extern int32_t hero_animation_speed; //lower is faster animation
78 extern byte *colordata;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern char *byte_conversion(int32_t number, int32_t format);
88 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
89 string zScript;
90 442 std::map<int32_t, script_slot_data > ffcmap;
91 442 std::map<int32_t, script_slot_data > globalmap;
92 442 std::map<int32_t, script_slot_data > genericmap;
93 442 std::map<int32_t, script_slot_data > itemmap;
94 442 std::map<int32_t, script_slot_data > npcmap;
95 442 std::map<int32_t, script_slot_data > ewpnmap;
96 442 std::map<int32_t, script_slot_data > lwpnmap;
97 442 std::map<int32_t, script_slot_data > playermap;
98 442 std::map<int32_t, script_slot_data > dmapmap;
99 442 std::map<int32_t, script_slot_data > screenmap;
100 442 std::map<int32_t, script_slot_data > itemspritemap;
101 442 std::map<int32_t, script_slot_data > comboscriptmap;
102 442 std::map<int32_t, script_slot_data > subscreenmap;
103 void free_newtilebuf();
104 bool combosread=false;
105 bool mapsread=false;
106 bool fixffcs=false;
107 bool fixpolsvoice=false;
108
109 // Each section had a separate, secondary versioning number, but it was never really utilized for
110 // its intended purpose so it's been removed. But we still write something in this field.
111 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
112 {
113 232 return p_iputw(section_version, f);
114 }
115
116 15132 bool read_deprecated_section_cversion(PACKFILE* f)
117 {
118 word unused;
119 15132 return p_igetw(&unused, f);
120 }
121
122 22013 void script_slot_data::update()
123 {
124
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 22006 times.
22013 switch (format)
125 {
126 case SCRIPT_FORMAT_INVALID:
127 7 output = fmt::format("{} --{}", slotname, scriptname);
128 7 break;
129 22006 case SCRIPT_FORMAT_DEFAULT:
130 default:
131 22006 output = fmt::format("{} {}", slotname, scriptname);
132 22006 }
133 22013 }
134
135 char qstdat_string[2048] = { 0 };
136
137 static zinfo* load_tmp_zi = NULL;
138
139 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
140 const byte clavio[9]={97,109,111,110,103,117,115,0};
141
142 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
143 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
144
145 const char *qst_error[] =
146 {
147 "OK","File not found","Invalid quest file",
148 "Version not supported","Obsolete version",
149 "Missing new data" , /* but let it pass in ZQuest */
150 "Internal error occurred", "Invalid password",
151 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
152 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
153 };
154
155 //for legacy quests -DD
156 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
157 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
158 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
159 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
160 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
161 };
162
163 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
164
165
166 char *byte_conversion(int32_t number, int32_t format)
167 {
168 static char num_str[40];
169
170 if(format==-1) //auto
171 {
172 format=1; //bytes
173
174 if(number>1024)
175 {
176 format=2; //kilobytes
177 }
178
179 if(number>1024*1024)
180 {
181 format=3; //megabytes
182 }
183
184 if(number>1024*1024*1024)
185 {
186 format=4; //gigabytes (dude, what are you doing?)
187 }
188 }
189
190 switch(format)
191 {
192 case 1: //bytes
193 sprintf(num_str,"%db",number);
194 break;
195
196 case 2: //kilobytes
197 sprintf(num_str,"%.2fk",float(number)/1024);
198 break;
199
200 case 3: //megabytes
201 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
202 break;
203
204 case 4: //gigabytes
205 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
206 break;
207
208 default:
209 abort();
210 break;
211 }
212
213 return num_str;
214 }
215
216 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
217 {
218 static char num_str1[40];
219 static char num_str2[40];
220 static char num_str[80];
221
222 if(format1==-1) //auto
223 {
224 format1=1; //bytes
225
226 if(number1>1024)
227 {
228 format1=2; //kilobytes
229 }
230
231 if(number1>1024*1024)
232 {
233 format1=3; //megabytes
234 }
235
236 if(number1>1024*1024*1024)
237 {
238 format1=4; //gigabytes (dude, what are you doing?)
239 }
240 }
241
242 if(format2==-1) //auto
243 {
244 format2=1; //bytes
245
246 if(number2>1024)
247 {
248 format2=2; //kilobytes
249 }
250
251 if(number2>1024*1024)
252 {
253 format2=3; //megabytes
254 }
255
256 if(number2>1024*1024*1024)
257 {
258 format2=4; //gigabytes (dude, what are you doing?)
259 }
260 }
261
262 switch(format1)
263 {
264 case 1: //bytes
265 sprintf(num_str1,"%db",number1);
266 break;
267
268 case 2: //kilobytes
269 sprintf(num_str1,"%.2fk",float(number1)/1024);
270 break;
271
272 case 3: //megabytes
273 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
274 break;
275
276 case 4: //gigabytes
277 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
278 break;
279
280 default:
281 abort();
282 break;
283 }
284
285 switch(format2)
286 {
287 case 1: //bytes
288 sprintf(num_str2,"%db",number2);
289 break;
290
291 case 2: //kilobytes
292 sprintf(num_str2,"%.2fk",float(number2)/1024);
293 break;
294
295 case 3: //megabytes
296 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
297 break;
298
299 case 4: //gigabytes
300 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
301 break;
302
303 default:
304 abort();
305 break;
306 }
307
308 sprintf(num_str, "%s/%s", num_str1, num_str2);
309 return num_str;
310 }
311
312 char *ordinal(int32_t num)
313 {
314 static const char *ending[4] = {"st","nd","rd","th"};
315 static char ord_str[8];
316
317 char *end;
318 int32_t t=(num%100)/10;
319 int32_t n=num%10;
320
321 if(n>=1 && n<4 && t!=1)
322 end = (char *)ending[n-1];
323 else
324 end = (char *)ending[3];
325
326 sprintf(ord_str,"%d%s",num%10000,end);
327 return ord_str;
328 }
329
330 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
331 {
332 int32_t ret;
333 *version=0;
334 *build=0;
335 byte temp_map_count=map_count;
336 byte temp_midi_flags[MIDIFLAGS_SIZE];
337 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
338
339 zquestheader tempheader{};
340
341 if(!f)
342 {
343 return qe_invalid;
344 }
345
346 ret=readheader(f, &tempheader);
347
348 if(ret)
349 {
350 return ret;
351 }
352
353 map_count=temp_map_count;
354 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
355 *version=tempheader.zelda_version;
356 *build=tempheader.build;
357 return 0;
358 }
359
360
361 bool find_section(PACKFILE *f, int32_t section_id_requested)
362 {
363
364 if(!f)
365 {
366 return false;
367 }
368
369 int32_t section_id_read;
370 bool catchup=false;
371 word dummy;
372 byte tempbyte;
373 char tempbuf[65536];
374
375
376 switch(section_id_requested)
377 {
378 case ID_RULES:
379 case ID_STRINGS:
380 case ID_MISC:
381 case ID_TILES:
382 case ID_COMBOS:
383 case ID_CSETS:
384 case ID_MAPS:
385 case ID_DMAPS:
386 case ID_DOORS:
387 case ID_ITEMS:
388 case ID_WEAPONS:
389 case ID_COLORS:
390 case ID_ICONS:
391 case ID_INITDATA:
392 case ID_GUYS:
393 case ID_MIDIS:
394 case ID_CHEATS:
395 break;
396
397 default:
398 al_trace("Bad section requested!\n");
399 return false;
400 break;
401 }
402
403 dword section_size;
404
405 //section id
406 if(!p_mgetl(&section_id_read,f))
407 {
408 return false;
409 }
410
411 while(!pack_feof(f))
412 {
413 switch(section_id_read)
414 {
415 case ID_RULES:
416 case ID_STRINGS:
417 case ID_MISC:
418 case ID_TILES:
419 case ID_COMBOS:
420 case ID_CSETS:
421 case ID_MAPS:
422 case ID_DMAPS:
423 case ID_DOORS:
424 case ID_ITEMS:
425 case ID_WEAPONS:
426 case ID_COLORS:
427 case ID_ICONS:
428 case ID_INITDATA:
429 case ID_GUYS:
430 case ID_MIDIS:
431 case ID_CHEATS:
432 catchup=false;
433 break;
434
435 default:
436 break;
437 }
438
439
440 while(catchup)
441 {
442 //section id
443 section_id_read=(section_id_read<<8);
444
445 if(!p_getc(&tempbyte,f))
446 {
447 return false;
448 }
449
450 section_id_read+=tempbyte;
451 }
452
453 if(section_id_read==section_id_requested)
454 {
455 return true;
456 }
457 else
458 {
459 //section version info
460 if(!p_igetw(&dummy,f))
461 {
462 return false;
463 }
464
465 if(!p_igetw(&dummy,f))
466 {
467 return false;
468 }
469
470 //section size
471 if(!p_igetl(&section_size,f))
472 {
473 return false;
474 }
475
476 //pack_fseek(f, section_size);
477 while(section_size>65535)
478 {
479 pfread(tempbuf,65535,f);
480 tempbuf[65535]=0;
481 section_size-=65535;
482 }
483
484 if(section_size>0)
485 {
486 pfread(tempbuf,section_size,f);
487 tempbuf[section_size]=0;
488 }
489 }
490
491 //section id
492 if(!p_mgetl(&section_id_read,f))
493 {
494 return false;
495 }
496 }
497
498 return false;
499 }
500
501
502
503
504
505 bool valid_zqt(PACKFILE *f)
506 {
507
508 //word tiles_used;
509 //word combos_used;
510 //open the file
511 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
512 if(!f)
513 return false;
514
515 //for now, everything else is valid
516 return true;
517
518 /*int16_t version;
519 byte build;
520
521 //read the version and make sure it worked
522 if(!p_igetw(&version,f))
523 {
524 goto error;
525 }
526
527 //read the build and make sure it worked
528 if(!p_getc(&build,f))
529 goto error;
530
531 //read the tile info and make sure it worked
532 if(!p_igetw(&tiles_used,f))
533 {
534 goto error;
535 }
536
537 for (int32_t i=0; i<tiles_used; i++)
538 {
539 if(!pfread(trashbuf,tilesize(tf4Bit),f))
540 {
541 goto error;
542 }
543 }
544
545 //read the combo info and make sure it worked
546 if(!p_igetw(&combos_used,f))
547 {
548 goto error;
549 }
550 for (int32_t i=0; i<combos_used; i++)
551 {
552 if(!pfread(trashbuf,sizeof(newcombo),f))
553 {
554 goto error;
555 }
556 }
557
558 //read the palette info and make sure it worked
559 for (int32_t i=0; i<48; i++)
560 {
561 if(!pfread(trashbuf,newpdTOTAL,f))
562 {
563 goto error;
564 }
565 }
566 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
567 {
568 goto error;
569 }
570 for (int32_t i=0; i<MAXLEVELS; i++)
571 {
572 if(!pfread(trashbuf,PALNAMESIZE,f))
573 {
574 goto error;
575 }
576 }
577
578 //read the sprite info and make sure it worked
579 for (int32_t i=0; i<MAXITEMS; i++)
580 {
581 if(!pfread(trashbuf,sizeof(itemdata),f))
582 {
583 goto error;
584 }
585 }
586
587 for (int32_t i=0; i<MAXWPNS; i++)
588 {
589 if(!pfread(trashbuf,sizeof(wpndata),f))
590 {
591 goto error;
592 }
593 }
594
595 //read the triforce pieces info and make sure it worked
596 for (int32_t i=0; i<8; ++i)
597 {
598 if(!p_getc(&trashbuf,f))
599 {
600 goto error;
601 }
602 }
603
604
605
606 //read the game icons info and make sure it worked
607 for (int32_t i=0; i<4; ++i)
608 {
609 if(!p_igetw(&trashbuf,f))
610 {
611 goto error;
612 }
613 }
614
615 //read the misc colors info and map styles info and make sure it worked
616 if(!pfread(trashbuf,sizeof(zcolors),f))
617 {
618 goto error;
619 }
620
621 //read the template screens and make sure it worked
622 byte num_maps;
623 if(!p_getc(&num_maps,f))
624 {
625 goto error;
626 }
627 for (int32_t i=0; i<TEMPLATES; i++)
628 {
629 if(!pfread(trashbuf,sizeof(mapscr),f))
630 {
631 goto error;
632 }
633 }
634 if (num_maps>1) //dungeon templates
635 {
636 for (int32_t i=0; i<TEMPLATES; i++)
637 {
638 if(!pfread(trashbuf,sizeof(mapscr),f))
639 {
640 goto error;
641 }
642 }
643 }
644
645 //yay! it worked! close the file and say everything was ok.
646 pack_fclose(f);
647 return true;
648
649 error:
650 pack_fclose(f);
651 return false;*/
652 }
653
654 bool valid_zqt(const char *filename)
655 {
656 PACKFILE *f=NULL;
657 bool isvalid;
658 int32_t error;
659 f=open_quest_file(&error, filename, false);
660
661 if(!f)
662 {
663 // setPackfilePassword(NULL);
664 return false;
665 }
666
667 isvalid=valid_zqt(f);
668
669 clear_quest_tmpfile();
670 pack_fclose(f);
671
672 // setPackfilePassword(NULL);
673 return isvalid;
674 }
675
676 /*
677 .qst file history
678
679 .qst files have always been compressed using allegro's packfiles.
680
681 At some point, an encoding layer was added. The two layers look like this:
682
683 1) The top layer is from us. See decode_file_007.
684 [0-24] Preamble "Zelda Classic Quest File"
685 [25-28] Initial decoding seed value.
686 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
687 [last 4] Checksum
688
689 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
690 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
691 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
692 The oldest quests skip the password part.
693
694 Simply, the job of this function is to peel away the top layer.
695
696 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
697 in opening and saving files. There is no version field, so they decryption key is
698 found via trial-by-error (very slow!)
699
700 There are other file types of interest:
701 - .zqt: quest template files, skips top-layer encryption pass
702 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
703 - .qu?: same as above. automated backup files
704 - .qb?: same as above. automated backup files
705 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
706
707 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
708 files are now "slh!.AG ZC Enhanced Quest File".
709 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
710 */
711 832 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
712 {
713
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (show_progress)
714 {
715 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
716 }
717
718 832 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
719
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 495 times.
832 if (unencrypted_result.decoded_pf)
720 337 return unencrypted_result.decoded_pf;
721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 if (unencrypted_result.not_found)
722 {
723 *open_error = qe_notfound;
724 return nullptr;
725 }
726
727 // Everything below here is legacy code - recently saved quest files will have
728 // returned by now.
729 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
730
731 // Note: although this is primarily for loading .qst files, it can also handle all of the
732 // file types mentioned in the comment above. No need to be told if the file being loaded
733 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
734 495 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
735 495 bool compressed = unencrypted_result.compressed;
736 495 bool encrypted = unencrypted_result.encrypted;
737
738 char tmpfilename[L_tmpnam];
739 495 temp_name(tmpfilename);
740 char percent_done[30];
741 495 int32_t current_method=0;
742
743 PACKFILE *f;
744 495 const char *passwd= encrypted ? datapwd : "";
745
746 // oldquest flag is set when an unencrypted qst file is suspected.
747 495 bool oldquest = false;
748 int32_t ret;
749
750
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(strcmp(filename, "default.qst")!=0)
751 {
752 495 box_out(filename);
753 495 }
754 else
755 {
756 box_out("new quest"); // Or whatever
757 }
758 495 box_out("...");
759 495 box_eol();
760 495 box_eol();
761
762
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(encrypted)
763 {
764 495 box_out("Decrypting...");
765 495 box_save_x();
766 495 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
767
768
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 63 times.
495 if(ret)
769 {
770
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
771 {
772 case 1:
773 box_out("error.");
774 box_eol();
775 box_end(true);
776 *open_error=qe_notfound;
777 return NULL;
778
779 case 2:
780 box_out("error.");
781 box_eol();
782 box_end(true);
783 *open_error=qe_internal;
784 return NULL;
785 // be sure not to delete tmpfilename now...
786 }
787
788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
789 {
790 63 current_method++;
791 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
792 63 box_out(percent_done);
793 63 box_load_x();
794 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
795 63 }
796
797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
798 {
799 63 current_method++;
800 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
801 63 box_out(percent_done);
802 63 box_load_x();
803 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
804 63 }
805
806
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
807 {
808 18 current_method++;
809 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
810 18 box_out(percent_done);
811 18 box_load_x();
812 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
813 18 }
814
815
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
816 {
817 12 current_method++;
818 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
819 12 box_out(percent_done);
820 12 box_load_x();
821 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
822 12 }
823
824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
825 {
826 oldquest = true;
827 passwd="";
828 }
829 63 }
830
831 495 box_out("okay.");
832 495 box_eol();
833 495 }
834 else
835 {
836 oldquest = true;
837 }
838
839 495 box_out("Opening...");
840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
841
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(!f)
842 {
843 if((compressed==1)&&(errno==EDOM))
844 {
845 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
846 }
847
848 if(!f)
849 {
850 if(!oldquest)
851 {
852 delete_file(tmpfilename);
853 }
854 box_out("error.");
855 box_eol();
856 box_end(true);
857 *open_error=qe_invalid;
858 return NULL;
859 }
860 }
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 if(!oldquest)
863 {
864 495 delete_file(tmpfilename);
865 495 }
866
867 495 box_out("okay.");
868 495 box_eol();
869
870 495 return f;
871 832 }
872
873 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
874 {
875 PACKFILE *f=NULL;
876 int32_t open_error=0;
877
878 if (Header->templatepath[0] != 0)
879 {
880 // TODO: should be safe to remove this, no one seems to use custom quest templates.
881 filename=Header->templatepath;
882 }
883
884 f=open_quest_file(&open_error, filename, false);
885
886 if(!f)
887 {
888 return NULL;
889 }
890
891 if(validate)
892 {
893 if(!valid_zqt(f))
894 {
895 displayinfo("Error", "Invalid Quest Template");
896 pack_fclose(f);
897 clear_quest_tmpfile();
898 return NULL;
899 }
900 }
901
902 return f;
903 }
904
905 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
906 {
907 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
908 if (get_app_id() == App::zelda)
909 assert(section_id == ID_TILES);
910
911 combosread=false;
912 mapsread=false;
913 fixffcs=false;
914
915 switch(section_id)
916 {
917 case ID_RULES:
918 case ID_STRINGS:
919 case ID_MISC:
920 case ID_TILES:
921 case ID_COMBOS:
922 case ID_CSETS:
923 case ID_MAPS:
924 case ID_DMAPS:
925 case ID_DOORS:
926 case ID_ITEMS:
927 case ID_WEAPONS:
928 case ID_COLORS:
929 case ID_ICONS:
930 case ID_INITDATA:
931 case ID_GUYS:
932 case ID_MIDIS:
933 case ID_CHEATS:
934 case ID_ITEMDROPSETS:
935 case ID_FAVORITES:
936 break;
937
938 default:
939 return false;
940 break;
941 }
942
943 int32_t ret;
944 word version, build;
945 PACKFILE *f=NULL;
946
947 //why is this here?
948 /*
949 if(colordata==NULL)
950 return false;
951 */
952
953 //setPackfilePassword(datapwd);
954 f=open_quest_template(Header, filename, validate);
955
956 if(!f) //no file, nothing to delete
957 {
958 // setPackfilePassword(NULL);
959 return false;
960 }
961
962 ret=get_version_and_build(f, &version, &build);
963
964 if(ret||(version==0))
965 {
966 pack_fclose(f);
967 clear_quest_tmpfile();
968
969 // setPackfilePassword(NULL);
970 return false;
971 }
972
973 if(!find_section(f, section_id))
974 {
975 al_trace("Can't find section!\n");
976 pack_fclose(f);
977 clear_quest_tmpfile();
978
979 //setPackfilePassword(NULL);
980 return false;
981 }
982
983 switch(section_id)
984 {
985 case ID_RULES:
986 //rules
987 ret=readrules(f, Header);
988 break;
989
990 case ID_STRINGS:
991 //strings
992 ret=readstrings(f, Header);
993 break;
994
995 case ID_MISC:
996 //misc data
997 ret=readmisc(f, Header, Misc);
998 break;
999
1000 case ID_TILES:
1001 //tiles
1002 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1003 break;
1004
1005 case ID_COMBOS:
1006 //combos
1007 clear_combos();
1008 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1009 combosread=true;
1010 break;
1011
1012 case ID_COMBOALIASES:
1013 //combos
1014 ret=readcomboaliases(f, Header, version, build);
1015 break;
1016
1017 case ID_CSETS:
1018 //color data
1019 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1020 break;
1021
1022 case ID_MAPS:
1023 //maps
1024 ret=readmaps(f, Header);
1025 mapsread=true;
1026 break;
1027
1028 case ID_DMAPS:
1029 //dmaps
1030 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1031 break;
1032
1033 case ID_DOORS:
1034 //door combo sets
1035 ret=readdoorcombosets(f, Header);
1036 break;
1037
1038 case ID_ITEMS:
1039 //items
1040 ret=readitems(f, version, build);
1041 break;
1042
1043 case ID_WEAPONS:
1044 //weapons
1045 ret=readweapons(f, Header);
1046 break;
1047
1048 case ID_COLORS:
1049 //misc. colors
1050 ret=readmisccolors(f, Header, Misc);
1051 break;
1052
1053 case ID_ICONS:
1054 //game icons
1055 ret=readgameicons(f, Header, Misc);
1056 break;
1057
1058 case ID_INITDATA:
1059 //initialization data
1060 ret=readinitdata(f, Header);
1061 break;
1062
1063 case ID_GUYS:
1064 //guys
1065 ret=readguys(f, Header);
1066 break;
1067
1068 case ID_MIDIS:
1069 //midis
1070 ret=readmidis(f, Header, tunes);
1071 break;
1072
1073 case ID_CHEATS:
1074 //cheat codes
1075 ret=readcheatcodes(f, Header);
1076 break;
1077
1078 case ID_ITEMDROPSETS:
1079 //item drop sets
1080 // Why is this one commented out?
1081 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1082 break;
1083
1084 case ID_FAVORITES:
1085 // favorite combos and aliases
1086 ret=readfavorites(f, version);
1087 break;
1088
1089 default:
1090 ret=-1;
1091 break;
1092 }
1093
1094 pack_fclose(f);
1095 clear_quest_tmpfile();
1096
1097 //setPackfilePassword(NULL);
1098 if(!ret)
1099 {
1100 return true;
1101 }
1102
1103 return false;
1104 }
1105
1106 bool init_tiles_for_190(bool validate, zquestheader *Header)
1107 {
1108 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1109 }
1110
1111 bool init_tiles(bool validate, zquestheader *Header)
1112 {
1113 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1114 }
1115
1116 bool init_combos(bool validate, zquestheader *Header)
1117 {
1118 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1119 }
1120
1121 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1122 {
1123 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1124 }
1125
1126 832 void init_spritelists()
1127 {
1128
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
832 if(FFCore.quest_format[vZelda] < 0x255)
1129 {
1130 617 guys.setMax(255);
1131 617 items.setMax(255);
1132 617 Ewpns.setMax(255);
1133 617 Lwpns.setMax(255);
1134 617 chainlinks.setMax(255);
1135 617 decorations.setMax(255);
1136 617 particles.setMax(255);
1137 617 }
1138 else
1139 {
1140 215 guys.setMax(255);
1141 215 items.setMax(255);
1142 215 Ewpns.setMax(255);
1143 215 Lwpns.setMax(255);
1144 215 chainlinks.setMax(255);
1145 215 decorations.setMax(255);
1146 215 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1147 }
1148 832 }
1149
1150 326 bool reset_items(bool validate, zquestheader *Header)
1151 {
1152 326 bool ret = true;
1153
1/2
✓ Branch 0 taken 326 times.
✗ Branch 1 not taken.
326 if (get_app_id() == App::zquest)
1154 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1155
1156
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 83456 times.
83782 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1157
1158 326 return ret;
1159 }
1160
1161 bool reset_guys()
1162 {
1163 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1164 init_guys(V_GUYS);
1165 return true;
1166 }
1167
1168 bool reset_wpns(bool validate, zquestheader *Header)
1169 {
1170 bool ret = true;
1171 if (get_app_id() == App::zquest)
1172 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1173
1174 for(int32_t i=0; i<MAXWPNS; i++)
1175 reset_weaponname(i);
1176
1177 return ret;
1178 }
1179
1180 bool reset_mapstyles(bool validate, miscQdata *Misc)
1181 {
1182 Misc->colors.blueframe_tile = 20044;
1183 Misc->colors.blueframe_cset = 0;
1184 Misc->colors.triforce_tile = 23461;
1185 Misc->colors.triforce_cset = 1;
1186 Misc->colors.triframe_tile = 18752;
1187 Misc->colors.triframe_cset = 1;
1188 Misc->colors.overworld_map_tile = 16990;
1189 Misc->colors.overworld_map_cset = 2;
1190 Misc->colors.HCpieces_tile = 21160;
1191 Misc->colors.HCpieces_cset = 8;
1192 Misc->colors.dungeon_map_tile = 19651;
1193 Misc->colors.dungeon_map_cset = 8;
1194 return true;
1195 }
1196
1197 1299893 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1198 {
1199 word v_weapon_data;
1200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1299893 times.
1299893 if(!p_igetw(&v_weapon_data,f))
1201 return qe_invalid;
1202
1203
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetw(&(data.flags), f))
1204 return qe_invalid;
1205
1206
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.moveflags), f))
1207 return qe_invalid;
1208
1209
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetw(&(data.wflags), f))
1210 return qe_invalid;
1211
1212
2/2
✓ Branch 0 taken 6499465 times.
✓ Branch 1 taken 1299893 times.
7799358 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1213 {
1214
1/2
✓ Branch 0 taken 6499465 times.
✗ Branch 1 not taken.
6499465 if (!p_getc(&(data.burnsprs[q]), f))
1215 return qe_invalid;
1216
1/2
✓ Branch 0 taken 6499465 times.
✗ Branch 1 not taken.
6499465 if (!p_getc(&(data.light_rads[q]), f))
1217 return qe_invalid;
1218 6499465 }
1219
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.glow_shape), f))
1220 return qe_invalid;
1221
1222
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.override_flags), f))
1223 return qe_invalid;
1224
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.tilew), f))
1225 return qe_invalid;
1226
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.tileh), f))
1227 return qe_invalid;
1228
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hxsz), f))
1229 return qe_invalid;
1230
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hysz), f))
1231 return qe_invalid;
1232
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hzsz), f))
1233 return qe_invalid;
1234
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hxofs), f))
1235 return qe_invalid;
1236
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hyofs), f))
1237 return qe_invalid;
1238
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.xofs), f))
1239 return qe_invalid;
1240
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.yofs), f))
1241 return qe_invalid;
1242
1243
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetzf(&(data.step), f))
1244 return qe_invalid;
1245
1246
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.unblockable), f))
1247 return qe_invalid;
1248
1249
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.timeout), f))
1250 return qe_invalid;
1251
1252
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.imitate_weapon), f))
1253 return qe_invalid;
1254
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.default_defense), f))
1255 return qe_invalid;
1256
1257
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.lift_level), f))
1258 return qe_invalid;
1259
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.lift_time), f))
1260 return qe_invalid;
1261
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetzf(&(data.lift_height), f))
1262 return qe_invalid;
1263
1264
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if(!p_igetw(&(data.script), f))
1265 return qe_invalid;
1266
2/2
✓ Branch 0 taken 10399144 times.
✓ Branch 1 taken 1299893 times.
11699037 for(uint q = 0; q < 8; ++q)
1267
1/2
✓ Branch 0 taken 10399144 times.
✗ Branch 1 not taken.
10399144 if(!p_igetl(&(data.initd[q]), f))
1268 return qe_invalid;
1269
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if(!p_igetw(&(data.pierce_count), f))
1270 return qe_invalid;
1271 1299893 return 0;
1272 1299893 }
1273
1274 445 int32_t get_qst_buffers()
1275 {
1276 445 TheMaps.resize(MAPSCRS);
1277 445 old_combo_pages.resize(MAPSCRS);
1278 445 map_infos.resize(1);
1279
1280 445 Z_message("OK\n");
1281
1282 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1283 // (Shoelace's "Hero of Dreams" uses 1415.)
1284 // So let's be a bit generous and allow 4096 initially.
1285 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1286 // I tested it and it worked without flaw on 6/6/11. - L.
1287 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1288 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1289 // See https://discord.com/channels/876899628556091432/992984989073416242
1290 445 msg_strings_size = 8192;
1291
1292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 MsgStrings = new MsgStr[msg_strings_size];
1293
1294 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1295
2/2
✓ Branch 0 taken 3645440 times.
✓ Branch 1 taken 445 times.
3645885 for(auto q = 0; q < msg_strings_size; ++q)
1296 {
1297 3645440 MsgStrings[q].clear();
1298 3645440 }
1299
1300
4/6
✓ Branch 0 taken 227840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227395 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 445 times.
✗ Branch 5 not taken.
227840 if((DMaps=new dmap[MAXDMAPS])==NULL)
1301 return 0;
1302
1303
1304
1305 445 combobuf.clear();
1306 445 combobuf.resize(MAXCOMBOS);
1307
1308
1309
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1310 return 0;
1311
1312 445 free_newtilebuf();
1313
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1314 return 0;
1315
1316 445 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1317 //Z_message("Performed memset on tiles\n");
1318 445 clear_tiles(newtilebuf);
1319 //Z_message("Performed clear_tiles()\n");
1320
1321
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 15 times.
445 if (get_app_id() == App::zquest)
1322 {
1323
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1324 return 0;
1325
1326 15 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1327 15 clear_tiles(grabtilebuf);
1328 15 }
1329
1330
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((trashbuf=(byte*)malloc(100000))==NULL)
1331 return 0;
1332
1333 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1334 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1335 // fixed by ensuring there's actually itemdata there.
1336 // If you change this, be sure to update del_qst_buffers, too.
1337
1338
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1339 return 0;
1340
1341
2/2
✓ Branch 0 taken 114365 times.
✓ Branch 1 taken 445 times.
114810 for(size_t q = 0; q < MAXITEMS+1; ++q)
1342 114365 itemsbuf[q].clear();
1343 445 itemsbuf++;
1344
1345
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1346 return 0;
1347
1348 445 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1349
1350
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1351 return 0;
1352
1353
2/2
✓ Branch 0 taken 227840 times.
✓ Branch 1 taken 445 times.
228285 for(size_t q = 0; q < MAXGUYS; ++q)
1354 227840 guysbuf[q].clear();
1355
1356
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1357 return 0;
1358
1359 445 return 1;
1360 445 }
1361
1362
1363 782 void free_newtilebuf()
1364 {
1365
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 442 times.
782 if(newtilebuf)
1366 {
1367
2/2
✓ Branch 0 taken 72930000 times.
✓ Branch 1 taken 340 times.
72930340 for(int32_t i=0; i<NEWMAXTILES; i++)
1368
2/2
✓ Branch 0 taken 643500 times.
✓ Branch 1 taken 72286500 times.
145216500 if(newtilebuf[i].data)
1369 72286500 free(newtilebuf[i].data);
1370
1371 340 free(newtilebuf);
1372 340 newtilebuf = 0;
1373 340 }
1374 782 }
1375
1376 337 void free_grabtilebuf()
1377 {
1378
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 11 times.
337 if (get_app_id() == App::zquest)
1379 {
1380
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1381 {
1382
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1384
1385 11 free(grabtilebuf);
1386 11 grabtilebuf = 0;
1387 11 }
1388 11 }
1389 337 }
1390
1391 337 void del_qst_buffers()
1392 {
1393
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 337 times.
✗ Branch 3 not taken.
337 if(MsgStrings) delete[] MsgStrings;
1394
1395
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 337 times.
✗ Branch 3 not taken.
337 if (DMaps) delete[] DMaps;
1396
1397 337 combobuf.clear();
1398
1399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(colordata) free(colordata);
1400
1401 337 free_newtilebuf();
1402 337 free_grabtilebuf();
1403
1404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(trashbuf) free(trashbuf);
1405
1406 // See get_qst_buffers
1407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(itemsbuf)
1408 {
1409 337 itemsbuf--;
1410 337 free(itemsbuf);
1411 337 }
1412
1413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(wpnsbuf) free(wpnsbuf);
1414
1415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(guysbuf) free(guysbuf);
1416
1417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(combo_class_buf) free(combo_class_buf);
1418 337 }
1419
1420 18 bool init_palnames()
1421 {
1422 // if(palnames==NULL)
1423 // return false;
1424
1425
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1426 {
1427
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1428 {
1429 case 0:
1430 18 sprintf(palnames[x],"Overworld");
1431 18 break;
1432
1433 case 10:
1434 18 sprintf(palnames[x],"Caves");
1435 18 break;
1436
1437 case 11:
1438 18 sprintf(palnames[x],"Passageways");
1439 18 break;
1440
1441 default:
1442 9162 sprintf(palnames[x],"%c",0);
1443 9162 break;
1444 }
1445 9216 }
1446
1447 18 return true;
1448 }
1449
1450 100662 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1451 {
1452 void *p;
1453
1454
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 p = _AL_MALLOC(MAX(size, alloc_size));
1455
1456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100662 times.
100662 if(!p)
1457 {
1458 return NULL;
1459 }
1460
1461
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(!pfread(p,size,f))
1462 {
1463 _AL_FREE(p);
1464 return NULL;
1465 }
1466
1467
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(pack_ferror(f))
1468 {
1469 _AL_FREE(p);
1470 return NULL;
1471 }
1472
1473 100662 return p;
1474 100662 }
1475
1476 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1477 static const byte* legacy_skip_flags;
1478
1479 /* read_midi:
1480 * Reads MIDI data from a datafile (this is not the same thing as the
1481 * standard midi file format).
1482 */
1483
1484 10331 static MIDI *read_midi(PACKFILE *f)
1485 {
1486 MIDI *m;
1487 int32_t c;
1488 10331 int16_t divisions=0;
1489 10331 int32_t len=0;
1490
1491 10331 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1492
1493
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!m)
1494 {
1495 return NULL;
1496 }
1497
1498
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1499 {
1500 330592 m->track[c].len = 0;
1501 330592 m->track[c].data = NULL;
1502 330592 }
1503
1504 10331 p_mgetw(&divisions,f);
1505 10331 m->divisions=divisions;
1506
1507
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1508 {
1509 330592 p_mgetl(&len,f);
1510 330592 m->track[c].len=len;
1511
1512
2/2
✓ Branch 0 taken 229930 times.
✓ Branch 1 taken 100662 times.
330592 if(m->track[c].len > 0)
1513 {
1514 100662 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1515
1516
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(!m->track[c].data)
1517 {
1518 destroy_midi(m);
1519 return NULL;
1520 }
1521 100662 }
1522 330592 }
1523
1524 LOCK_DATA(m, sizeof(MIDI));
1525
1526
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1527 {
1528
2/2
✓ Branch 0 taken 100662 times.
✓ Branch 1 taken 229930 times.
330592 if(m->track[c].data)
1529 {
1530 LOCK_DATA(m->track[c].data, m->track[c].len);
1531 100662 }
1532 330592 }
1533
1534 10331 return m;
1535 10331 }
1536
1537 void clear_combo(int32_t i)
1538 {
1539 combobuf[i].clear();
1540 }
1541
1542 void clear_combos()
1543 {
1544 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1545 clear_combo(tmpcounter);
1546 }
1547
1548 void pack_combos()
1549 {
1550 int32_t di = 0;
1551
1552 for(int32_t si=0; si<1024; si+=2)
1553 combobuf[di++] = combobuf[si];
1554
1555 for(; di<1024; di++)
1556 clear_combo(di);
1557 }
1558
1559 497 void reset_tunes(zctune *tune)
1560 {
1561
2/2
✓ Branch 0 taken 125244 times.
✓ Branch 1 taken 497 times.
125741 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1562 {
1563 125244 tune[i].reset();
1564 125244 }
1565 497 }
1566
1567 int32_t doortranslations_u[9][4]=
1568 {
1569 {37,38,53,54},
1570 {37,38,39,40},
1571 {37,38,55,56},
1572 {37,38,39,40},
1573 {37,38,53,54},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {7,8,23,24},
1577 {7,8,41,42}
1578 };
1579
1580 int32_t doortranslations_d[9][4]=
1581 {
1582 {117,118,133,134},
1583 {135,136,133,134},
1584 {119,120,133,134},
1585 {135,136,133,134},
1586 {117,118,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {151,152,167,168},
1590 {137,138,167,168},
1591 };
1592
1593 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1594 int32_t doortranslations_l[9][6]=
1595 {
1596 {66,67,82,83,98,99},
1597 {66,68,82,84,98,100},
1598 {66,69,82,85,98,101},
1599 {66,68,82,84,98,100},
1600 {66,67,82,83,98,99},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {64,65,80,81,96,97},
1604 {64,65,80,114,96,97},
1605 };
1606
1607 int32_t doortranslations_r[9][6]=
1608 {
1609
1610 {76,77,92,93,108,109},
1611 {75,77,91,93,107,109},
1612 {74,77,90,93,106,109},
1613 {75,77,91,93,107,109},
1614 {76,77,92,93,108,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {78,79,94,95,110,111},
1618 {78,79,125,95,110,111},
1619 };
1620
1621 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1622 {
1623 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1624 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1625 }
1626
1627 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1628 {
1629 //these are here to bypass compiler warnings about unused arguments
1630 840750 map=map;
1631 840750 scr=scr;
1632 840750 pos=pos;
1633
1634 //what does this function do?
1635 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1636 840750 return 2;
1637 }
1638
1639 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1640 {
1641
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1642 {
1643 18423 return 0;
1644 }
1645
1646 4425 DoorComboSet tempdcs{};
1647
1648 //up
1649
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1650 {
1651
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1652 {
1653 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1654 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1655 159300 }
1656 39825 }
1657
1658 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1659 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1660 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1661 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1662 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1663 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1664
1665 //down
1666
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1667 {
1668
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1669 {
1670 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1671 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1672 159300 }
1673 39825 }
1674
1675 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1676
1677 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1678 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1679 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1680 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1681 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1682
1683 //left
1684 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1685
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1686 {
1687
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1688 {
1689 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1690 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1691 238950 }
1692 39825 }
1693
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1695 {
1696 if((j!=2)&&(j!=3))
1697 {
1698 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1699 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1700 }
1701 }
1702
1703 4425 tempdcs.bombdoorcombo_l[0]=0;
1704 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1705 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1706 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1707 4425 tempdcs.bombdoorcombo_l[2]=0;
1708 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1709 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1710 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1711
1712 //right
1713
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1714 {
1715
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1716 {
1717 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1718 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1719 238950 }
1720 39825 }
1721
1722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1723 {
1724 if((j!=2)&&(j!=3))
1725 {
1726 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1727 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1728 }
1729 }
1730
1731 4425 tempdcs.bombdoorcombo_r[0]=0;
1732 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1733 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1734 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1735 4425 tempdcs.bombdoorcombo_r[2]=0;
1736 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1737 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1738 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1739
1740 int32_t k;
1741
1742
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1743 {
1744
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1745 {
1746 4365 break;
1747 }
1748 5941 }
1749
1750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1751 {
1752 return 0;
1753 }
1754
1755
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1756 {
1757 60 DoorComboSets[k]=tempdcs;
1758 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1759 60 ++door_combo_set_count;
1760 60 }
1761
1762 4425 return k;
1763 /*
1764 doorcombo_u[9][4];
1765 doorcset_u[9][4];
1766 doorcombo_d[9][4];
1767 doorcset_d[9][4];
1768 doorcombo_l[9][6];
1769 doorcset_l[9][6];
1770 doorcombo_r[9][6];
1771 doorcset_r[9][6];
1772 bombdoorcombo_u[2];
1773 bombdoorcset_u[2];
1774 bombdoorcombo_d[2];
1775 bombdoorcset_d[2];
1776 bombdoorcombo_l[3];
1777 bombdoorcset_l[3];
1778 bombdoorcombo_r[3];
1779 bombdoorcset_r[3];
1780 walkthroughcombo[4];
1781 walkthroughcset[4];
1782 */
1783 22848 }
1784
1785 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1786 {
1787 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1788 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1789 }
1790
1791 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1792 {
1793
1794 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1795 }
1796
1797 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1798 {
1799 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1800 }
1801
1802
1803 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1804 {
1805 char temp_pwd[30];
1806 83 memset(temp_pwd,0,30);
1807
1808
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1809 {
1810 75 memcpy(temp_pwd,encrypted_pwd,30);
1811 75 temp_pwd[29]=0;
1812
1813
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1814 {
1815 2250 temp_pwd[i] -= pwdkey;
1816 2250 int32_t t=pwdkey>>15;
1817 2250 pwdkey = (pwdkey<<1)+t;
1818 2250 }
1819 75 }
1820
1821 83 memcpy(pwd,temp_pwd,30);
1822 83 }
1823
1824
1825 262 bool devpwd()
1826 {
1827 #ifdef _DEBUG
1828 return true;
1829 #endif
1830 #if DEVLEVEL > 3
1831 return true;
1832 #endif
1833
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1834 }
1835 bool check_questpwd(zquestheader *Header, char *pwd)
1836 {
1837 if(devpwd())
1838 return true;
1839 if((!strcmp(pwd, (char*)clavio)))
1840 return true;
1841 cvs_MD5Context ctx;
1842 uint8_t md5sum[16];
1843
1844 cvs_MD5Init(&ctx);
1845 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1846 cvs_MD5Final(md5sum, &ctx);
1847
1848 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1849 }
1850
1851 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1852 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1853 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1854
1855 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1856 {
1857 char keyfilename[2048];
1858 replace_extension(keyfilename, path, ext, 2047);
1859 if(!exists(keyfilename))
1860 return false;
1861 bool ret = false;
1862
1863 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1864 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1865 char msg[80] = {0};
1866 pfread(msg, 80, fp);
1867 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1868 {
1869 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1870 pack_fclose(fp);
1871 return false;
1872 }
1873 int16_t ver;
1874 byte bld;
1875 p_igetw(&ver, fp);
1876 p_getc(&bld, fp);
1877 pfread(password, QSTPWD_LEN, fp, true);
1878 if(hashed)
1879 {
1880 char unhashed_pw[QSTPWD_LEN] = {0};
1881
1882 char hashmap = 'Z';
1883 hashmap += 'Q';
1884 hashmap += 'U';
1885 hashmap += 'E';
1886 hashmap += 'S';
1887 hashmap += 'T';
1888
1889 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1890 unhashed_pw[q] = password[q] - hashmap;
1891
1892 ret = check_questpwd(Header, unhashed_pw);
1893 }
1894 else ret = check_questpwd(Header, password);
1895 pack_fclose(fp);
1896 zprint2("Found %s Key File '%s' (%s access)\n",
1897 typestr, keyfilename, ret ? "valid" : "invalid");
1898 return ret;
1899 }
1900
1901 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1902 {
1903 char exedir[PATH_MAX] = {0};
1904 extract_name(path, exedir, FILENAMEALL);
1905 char const* paths[] = {path, exedir};
1906 for(uint keyty : types)
1907 {
1908 if(keyty >= KEYFILE_NUMTY)
1909 continue;
1910 for(char const* p : paths)
1911 {
1912 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1913 return true;
1914 }
1915 }
1916 return false;
1917 }
1918
1919 498 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1920 {
1921 498 zprint2("\n");
1922 498 zprint2("[QUEST METADATA]\n");
1923
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 if(path)
1924 498 zprint2("Path: %s\n", path);
1925
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 128 times.
498 if(tempheader.title[0])
1926 370 zprint2("Title: %s\n", tempheader.title);
1927 498 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1928
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 283 times.
498 if(tempheader.new_version_id_date_day)
1929 215 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1930
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 220 times.
498 if(tempheader.version[0])
1931 278 zprint2("Qst Version: %s\n", tempheader.version);
1932
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 128 times.
498 if(tempheader.author[0])
1933 370 zprint2("Author: %s\n", tempheader.author);
1934 498 zprint2("\n");
1935 498 }
1936
1937 844 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1938 {
1939 int32_t dummy;
1940 844 zquestheader tempheader{};
1941
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 12 times.
844 tempheader.filename = Header->filename;
1942 char dummybuf[80];
1943 byte temp_map_count;
1944 byte temp_midi_flags[MIDIFLAGS_SIZE];
1945 word version;
1946 char temp_pwd[30], temp_pwd2[30];
1947 int16_t temp_pwdkey;
1948 cvs_MD5Context ctx;
1949 832 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1950 832 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1951
1952
1953
1954
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1955 {
1956 Z_message("Unable to read header string\n");
1957 return qe_invalid;
1958 }
1959
1960 // check header
1961
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1962 {
1963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1964 {
1965 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1966 return qe_invalid;
1967 }
1968 24 }
1969
1970 832 int32_t templatepath_len=0;
1971
1972 832 tempheader.external_zinfo = false;
1973 832 read_zinfo = false;
1974
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 808 times.
832 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1975 {
1976 byte padding;
1977
1978
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1979 {
1980 return qe_invalid;
1981 }
1982
1983
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1984 {
1985 return qe_invalid;
1986 }
1987
1988 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1989
1990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1991 {
1992 return qe_version;
1993 }
1994
1995 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1996
1997
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1998 {
1999 return qe_invalid;
2000 }
2001
2002
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2003 {
2004 return qe_obsolete;
2005 }
2006
2007
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2008 {
2009 return qe_invalid;
2010 }
2011
2012
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2013 {
2014 return qe_invalid;
2015 }
2016
2017 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2018
2019
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2020 {
2021 return qe_invalid;
2022 }
2023
2024
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2025 {
2026 return qe_invalid;
2027 }
2028
2029 24 FFCore.quest_format[qMapCount] = temp_map_count;
2030
2031
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2032 {
2033 return qe_invalid;
2034 }
2035
2036
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2037 {
2038 return qe_invalid;
2039 }
2040
2041
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2042 {
2043 return qe_invalid;
2044 }
2045
2046
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2047 {
2048 return qe_invalid;
2049 }
2050
2051
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2052 {
2053 return qe_invalid;
2054 }
2055
2056
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2057 {
2058 return qe_invalid;
2059 }
2060
2061
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2062 {
2063 return qe_invalid;
2064 }
2065
2066
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2067 {
2068 return qe_invalid;
2069 }
2070
2071
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2072 {
2073 return qe_invalid;
2074 }
2075 // These fields are expected to end in null bytes!
2076 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2077
2078
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2079 {
2080 return qe_invalid;
2081 }
2082 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2083
2084
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2085 {
2086 return qe_invalid;
2087 }
2088
2089
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2090 {
2091 return qe_invalid;
2092 }
2093
2094
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2095 {
2096 return qe_invalid;
2097 }
2098
2099 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2100
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2103
2104
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2105 {
2106 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2107 // Not anymore...
2108 memset(tempheader.minver,0,17);
2109 tempheader.build=0;
2110 tempheader.use_keyfile=0;
2111 memset(tempheader.old_foo, 0, 9);
2112 }
2113 else
2114 {
2115
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2116 {
2117 return qe_invalid;
2118 }
2119
2120
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2121 {
2122 return qe_invalid;
2123 }
2124
2125 24 FFCore.quest_format[vBuild] = tempheader.build;
2126
2127
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2128 {
2129 return qe_invalid;
2130 }
2131
2132
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2133 {
2134 return qe_invalid;
2135 }
2136 } // starting at minver
2137
2138
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2139 {
2140 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2141 6 }
2142 else
2143 {
2144
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2145 {
2146 return qe_invalid; // starting at rules3
2147 }
2148
2149
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2150 {
2151
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2152 12 }
2153 }
2154
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2155
2156
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2157
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2158 {
2159
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2160
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2162 18 }
2163
2164
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2165 {
2166 6 byte *mf=temp_midi_flags;
2167
2168
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2169 {
2170 4 mf=(byte*)dummybuf;
2171 4 }
2172
2173
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2174 {
2175 return qe_invalid; // starting at foo2
2176 }
2177
2178
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2179 {
2180 return qe_invalid; // starting at foo2
2181 }
2182 6 }
2183
2184
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2185
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2186 {
2187 18 memset(tempheader.templatepath,0,2048);
2188 18 }
2189 else
2190 {
2191 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2192 {
2193 return qe_invalid;
2194 }
2195 }
2196
2197
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2198
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2199 {
2200 24 tempheader.use_keyfile=0;
2201 24 }
2202 24 }
2203 else
2204 {
2205 //section id
2206
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_mgetl(&dummy,f))
2207 {
2208 return qe_invalid;
2209 }
2210
2211 //section version info
2212
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&version,f))
2213 {
2214 return qe_invalid;
2215 }
2216
2217
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (version > V_HEADER)
2218 return qe_version;
2219
2220 808 FFCore.quest_format[vHeader] = version;
2221
2222
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&dummy,f))
2223 {
2224 return qe_invalid;
2225 }
2226
2227 //section size
2228
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&dummy,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 //finally... section data
2234
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&tempheader.zelda_version,f))
2235 {
2236 return qe_invalid;
2237 }
2238
2239 808 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2240
2241 //do some quick checking...
2242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(tempheader.zelda_version > ZELDA_VERSION)
2243 {
2244 return qe_version;
2245 }
2246
2247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2248 {
2249 return qe_invalid;
2250 }
2251
2252
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(bad_version(tempheader.zelda_version))
2253 {
2254 return qe_obsolete;
2255 }
2256
2257
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.build,f))
2258 {
2259 return qe_invalid;
2260 }
2261
2262 808 FFCore.quest_format[vBuild] = tempheader.build;
2263
2264
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 749 times.
808 if(version<3)
2265 {
2266
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2267 {
2268 return qe_invalid;
2269 }
2270
2271
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2272 {
2273 return qe_invalid;
2274 }
2275
2276 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2277
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2278
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2279
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2280 59 }
2281 else
2282 {
2283
2/4
✓ Branch 0 taken 749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 749 times.
✗ Branch 3 not taken.
749 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2284 {
2285 return qe_invalid;
2286 }
2287 }
2288
2289
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&tempheader.internal,f))
2290 {
2291 return qe_invalid;
2292 }
2293
2294
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.quest_number,f))
2295 {
2296 return qe_invalid;
2297 }
2298
2299 808 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2300
2301 808 size_t versz = version < 8 ? 9 : 16;
2302
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.version,versz,f))
2303 {
2304 return qe_invalid;
2305 }
2306
2307 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2308 //needs to be copied as char[9] or stored as a s.str
2309
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.minver,versz,f))
2310 {
2311 return qe_invalid;
2312 }
2313
2314 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2315
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2316 {
2317 return qe_invalid;
2318 }
2319 808 tempheader.title[sizeof(tempheader.title)-1] = 0;
2320
2321
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2322 {
2323 return qe_invalid;
2324 }
2325 808 tempheader.author[sizeof(tempheader.author)-1] = 0;
2326
2327
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.use_keyfile,f))
2328 {
2329 return qe_invalid;
2330 }
2331
2332 /*
2333 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2334 {
2335 return qe_invalid;
2336 }
2337 */
2338
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2339 {
2340 return qe_invalid;
2341 }
2342
2343
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(&dummybuf,4,f))
2344 {
2345 return qe_invalid;
2346 }
2347
2348
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2349 {
2350 return qe_invalid;
2351 }
2352
2353
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(dummybuf,14,f))
2354 {
2355 return qe_invalid;
2356 }
2357
2358 808 templatepath_len=sizeof(tempheader.templatepath);
2359
2360
2/2
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 59 times.
808 if(version==1)
2361 {
2362 59 templatepath_len=280;
2363 59 }
2364
2365
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.templatepath,templatepath_len,f))
2366 {
2367 return qe_invalid;
2368 }
2369
2370
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&temp_map_count,f))
2371 {
2372 return qe_invalid;
2373 }
2374
2375
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if(version>=4)
2376 {
2377
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_major,f))
2378 {
2379 return qe_invalid;
2380 }
2381
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_minor,f))
2382 {
2383 return qe_invalid;
2384 }
2385
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_patch,f))
2386 {
2387 return qe_invalid;
2388 }
2389
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_beta,f))
2398 {
2399 return qe_invalid;
2400 }
2401
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2402 {
2403 return qe_invalid;
2404 }
2405
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_release,f))
2406 {
2407 return qe_invalid;
2408 }
2409
2410 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2411
3/6
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
215 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2412 tempheader.version_minor = 55;
2413
2414
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_month,f))
2419 {
2420 return qe_invalid;
2421 }
2422
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_day,f))
2423 {
2424 return qe_invalid;
2425 }
2426
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2427 {
2428 return qe_invalid;
2429 }
2430
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2431 {
2432 return qe_invalid;
2433 }
2434
2435
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_devsig,256,f))
2436 {
2437 return qe_invalid;
2438 }
2439
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2440 strcpy(tempheader.new_version_devsig, "EmilyV99");
2441
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_compilername,256,f))
2442 {
2443 return qe_invalid;
2444 }
2445
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_compilerversion,256,f))
2446 {
2447 return qe_invalid;
2448 }
2449
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.product_name,1024,f))
2450 {
2451 return qe_invalid;
2452 }
2453
2454
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.compilerid,f))
2455 {
2456 return qe_invalid;
2457 }
2458
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2459 {
2460 return qe_invalid;
2461 }
2462
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2463 {
2464 return qe_invalid;
2465 }
2466
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2467 {
2468 return qe_invalid;
2469 }
2470
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2471 {
2472 return qe_invalid;
2473 }
2474
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetw(&tempheader.developerid,f))
2475 {
2476 return qe_invalid;
2477 }
2478
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.made_in_module_name,1024,f))
2479 {
2480 return qe_invalid;
2481 }
2482
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_datestamp,256,f))
2483 {
2484 return qe_invalid;
2485 }
2486
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_timestamp,256,f))
2487 {
2488 return qe_invalid;
2489 }
2490 215 }
2491 else // <4
2492 {
2493 593 tempheader.version_major = 0;
2494 593 tempheader.version_minor = 0;
2495 593 tempheader.version_patch = 0;
2496 593 tempheader.new_version_id_fourth = 0;
2497 593 tempheader.new_version_id_alpha = 0;
2498 593 tempheader.new_version_id_beta = 0;
2499 593 tempheader.new_version_id_gamma = 0;
2500 593 tempheader.new_version_id_release = 0;
2501 593 tempheader.new_version_id_date_year = 0;
2502 593 tempheader.new_version_id_date_month = 0;
2503 593 tempheader.new_version_id_date_day = 0;
2504 593 tempheader.new_version_id_date_hour = 0;
2505 593 tempheader.new_version_id_date_minute = 0;
2506
2507 593 memset(tempheader.new_version_devsig, 0, 256);
2508 593 memset(tempheader.new_version_compilername, 0, 256);
2509 593 memset(tempheader.new_version_compilerversion, 0, 256);
2510 593 memset(tempheader.product_name, 0, 1024);
2511 593 strcpy(tempheader.product_name, "ZQuest Classic");
2512
2513 593 tempheader.compilerid = 0;
2514 593 tempheader.compilerversionnumber_first = 0;
2515 593 tempheader.compilerversionnumber_second = 0;
2516 593 tempheader.compilerversionnumber_third = 0;
2517 593 tempheader.compilerversionnumber_fourth = 0;
2518 593 tempheader.developerid = 0;
2519
2520 593 memset(tempheader.made_in_module_name, 0, 1024);
2521 593 memset(tempheader.build_datestamp, 0, 256);
2522 593 memset(tempheader.build_timestamp, 0, 256);
2523 }
2524
2525
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if ( version >= 5 )
2526 {
2527
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_timezone,6,f))
2528 {
2529 return qe_invalid;
2530 }
2531 215 }
2532 else // < 5
2533 {
2534 593 memset(tempheader.build_timezone, 0, 6);
2535 }
2536
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if ( version >= 6 )
2537 {
2538 byte b;
2539
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&b,f))
2540 {
2541 return qe_invalid;
2542 }
2543 215 tempheader.external_zinfo = b?true:false;
2544 215 read_zinfo = true;
2545 215 }
2546
2547
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if(version >= 7)
2548 {
2549
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2550 {
2551 return qe_invalid;
2552 }
2553 215 }
2554 else
2555 {
2556 593 tempheader.new_version_is_nightly = false;
2557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593 times.
593 if(tempheader.zelda_version < 0x255)
2558 {
2559
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
593 switch(tempheader.zelda_version)
2560 {
2561 case 0x254:
2562 tempheader.version_major = 2;
2563 tempheader.version_minor = 54;
2564 break;
2565 case 0x250:
2566
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 415 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
534 switch(tempheader.build)
2567 {
2568 case 19:
2569 tempheader.version_major = 2;
2570 tempheader.version_minor = 50;
2571 tempheader.new_version_id_gamma = 1;
2572 break;
2573 case 20:
2574 tempheader.version_major = 2;
2575 tempheader.version_minor = 50;
2576 tempheader.new_version_id_gamma = 2;
2577 break;
2578 case 21:
2579 tempheader.version_major = 2;
2580 tempheader.version_minor = 50;
2581 tempheader.new_version_id_gamma = 3;
2582 break;
2583 case 22:
2584 tempheader.version_major = 2;
2585 tempheader.version_minor = 50;
2586 tempheader.new_version_id_gamma = 4;
2587 break;
2588 case 23:
2589 tempheader.version_major = 2;
2590 tempheader.version_minor = 50;
2591 tempheader.new_version_id_gamma = 5;
2592 break;
2593 case 24:
2594 31 tempheader.version_major = 2;
2595 31 tempheader.version_minor = 50;
2596 31 tempheader.new_version_id_release = -1;
2597 31 break;
2598 case 25:
2599 tempheader.version_major = 2;
2600 tempheader.version_minor = 50;
2601 tempheader.version_patch = 1;
2602 tempheader.new_version_id_gamma = 1;
2603 break;
2604 case 26:
2605 24 tempheader.version_major = 2;
2606 24 tempheader.version_minor = 50;
2607 24 tempheader.version_patch = 1;
2608 24 tempheader.new_version_id_gamma = 2;
2609 24 break;
2610 case 27:
2611 tempheader.version_major = 2;
2612 tempheader.version_minor = 50;
2613 tempheader.version_patch = 1;
2614 tempheader.new_version_id_gamma = 3;
2615 break;
2616 case 28:
2617 6 tempheader.version_major = 2;
2618 6 tempheader.version_minor = 50;
2619 6 tempheader.version_patch = 1;
2620 6 tempheader.new_version_id_release = -1;
2621 6 break;
2622 case 29:
2623 415 tempheader.version_major = 2;
2624 415 tempheader.version_minor = 50;
2625 415 tempheader.version_patch = 2;
2626 415 tempheader.new_version_id_release = -1;
2627 415 break;
2628 case 30:
2629 tempheader.version_major = 2;
2630 tempheader.version_minor = 50;
2631 tempheader.version_patch = 3;
2632 tempheader.new_version_id_gamma = 1;
2633 break;
2634 case 31:
2635 16 tempheader.version_major = 2;
2636 16 tempheader.version_minor = 53;
2637 16 tempheader.new_version_id_gamma = -1;
2638 16 break;
2639 case 32:
2640 29 tempheader.version_major = 2;
2641 29 tempheader.version_minor = 53;
2642 29 tempheader.new_version_id_release = -1;
2643 29 break;
2644 case 33:
2645 13 tempheader.version_major = 2;
2646 13 tempheader.version_minor = 53;
2647 13 tempheader.version_patch = 1;
2648 13 break;
2649 }
2650 534 break;
2651
2652 case 0x211:
2653 tempheader.version_major = 2;
2654 tempheader.version_minor = 11;
2655 tempheader.new_version_id_beta = tempheader.build;
2656 break;
2657 case 0x210:
2658 59 tempheader.version_major = 2;
2659 59 tempheader.version_minor = 10;
2660 59 tempheader.new_version_id_beta = tempheader.build;
2661 59 break;
2662 }
2663 593 }
2664 }
2665
2666
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 638 times.
808 if (version>=9)
2667 {
2668 170 std::string version_string;
2669
2/4
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
170 if(!p_getcstr(&version_string, f))
2670 {
2671 return qe_invalid;
2672 }
2673
2674 170 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2675 170 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 }
2677 else
2678 {
2679 638 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2680 }
2681 }
2682
2683
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 774 times.
832 if(printmetadata)
2684 {
2685
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2686 58 }
2687
2688 //{ Version Warning
2689
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 int32_t vercmp = tempheader.compareVer();
2690
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2691
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2692
4/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 662 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170 times.
1002 if(vercmp > 0 || (!vercmp &&
2693
2/4
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
170 (astatecmp > 0 || (!astatecmp &&
2694 170 avercmp > 0))))
2695 {
2696 bool r = true;
2697 if(loadquest_report)
2698 {
2699 enter_sys_pal();
2700 r = alert_confirm("Quest saved in newer version",
2701 "This quest was last saved in a newer version of ZQuest."
2702 " Attempting to load this quest may not work correctly; to"
2703 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2704 "\n\nWould you like to continue loading anyway? (Not recommended)");
2705 exit_sys_pal();
2706 }
2707 if(!r)
2708 return qe_silenterr;
2709 }
2710 //}
2711
2712 832 read_ext_zinfo = tempheader.external_zinfo;
2713
2714
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 *Header = tempheader;
2715 832 map_count=temp_map_count;
2716 832 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2717
2718
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 unpack_qrs();
2719
2720 832 return 0;
2721 856 }
2722
2723 11589 int32_t readrules(PACKFILE *f, zquestheader *Header)
2724 {
2725
2/2
✓ Branch 0 taken 11566 times.
✓ Branch 1 taken 23 times.
11589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11589 times.
11589 if (should_skip)
2727 return 0;
2728
2729 int32_t dummy;
2730 11589 zquestheader tempheader = *Header;
2731 11589 word s_version=0;
2732 11589 dword compatrule_version=0;
2733
2734
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 11115 times.
11589 if(tempheader.zelda_version >= 0x193)
2735 {
2736 //section version info
2737
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
2738 {
2739 return qe_invalid;
2740 }
2741
2742
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_RULES)
2743 return qe_version;
2744
2745 474 FFCore.quest_format[vRules] = s_version;
2746
2747
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&dummy,f))
2748 {
2749 return qe_invalid;
2750 }
2751
2752
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 259 times.
474 if(s_version > 16)
2753 {
2754
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&compatrule_version,f))
2755 {
2756 return qe_invalid;
2757 }
2758 215 }
2759 474 FFCore.quest_format[vCompatRule] = compatrule_version;
2760
2761 //section size
2762
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
2763 {
2764 return qe_invalid;
2765 }
2766
2767
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 215 times.
474 if ( s_version < 15 )
2768 {
2769 //finally... section data
2770
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2771 {
2772 return qe_invalid;
2773 }
2774 259 }
2775 else
2776 {
2777
2778
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2779 {
2780 return qe_invalid;
2781 }
2782
2783 }
2784 474 }
2785
2786 //{ bunch of compat stuff
2787 11589 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2788
2789
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 11092 times.
11589 unpack_qrs();
2790
2791
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<2)
2792 {
2793
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2796
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2797
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2803
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2804
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2805
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2806
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2807
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2812 82 }
2813
2814 //Now, do any updates...
2815
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
497 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2816 {
2817
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2818
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2819
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2820
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2821
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2822 82 }
2823
2824
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2825 {
2826
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2827 23 }
2828
2829
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2830 {
2831
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2832 23 }
2833
2834
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2835 {
2836
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2837 23 }
2838
2839
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version <= 0x210)
2840 {
2841
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2842 82 }
2843
2844
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 438 times.
497 if(tempheader.zelda_version == 0x210)
2845 {
2846
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2847
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2848
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2849 59 }
2850
2851
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version <= 0x210)
2852 {
2853
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2854
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2855 82 }
2856
2857 //might not be correct
2858
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(tempheader.zelda_version < 0x210)
2859 {
2860
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2861
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2862
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2863 23 }
2864
2865
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version < 0x211)
2866 {
2867
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2868 82 }
2869
2870
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
497 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2871 {
2872
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 475 times.
497 set_qr(qr_192b163_WARP,1);
2873 22 }
2874
2875
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 37 times.
22 if(tempheader.zelda_version == 0x210)
2876 {
2877
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2878
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2879
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2880 59 }
2881
2882
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
96 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2883 {
2884
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 237 times.
319 set_qr(qr_OLDPICKUP,1);
2885 82 }
2886
2887
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
497 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2888 {
2889
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2890
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2891 82 }
2892
2893
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2894 {
2895
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2896 82 }
2897
2898
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 297 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
497 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2899 {
2900
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2901 31 }
2902
2903
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
497 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2904 {
2905
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2906 82 }
2907
2908
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
297 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2909 {
2910
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2911 82 }
2912
2913
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
297 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2914 {
2915
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2916 137 }
2917
2918
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2919 {
2920
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 126 times.
263 set_qr(qr_OFFSCREENWEAPONS, 1);
2921 137 }
2922
2923 //Bombchu fix.
2924
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 200 times.
352 if(tempheader.zelda_version == 0x250)
2925 {
2926
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2927 {
2928
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2929 31 }
2930
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2931 {
2932
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2933 6 }
2934
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2935 {
2936
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2937 81 }
2938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2939 {
2940 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2941 }
2942 200 }
2943
2944
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2945 {
2946 // qr_OFFSETEWPNCOLLISIONFIX
2947 // All 'official' quests need this disabled.
2948 // All 2.10 and lower quests need this enabled to preseve compatability.
2949 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2950
2951 //~Gleeok
2952
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 120 times.
263 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2953
2954 // Broke in build 695
2955
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2956
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2957 143 }
2958
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 595 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 595 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 578 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
358 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2959 {
2960
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2961 22 }
2962
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 228 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 13 times.
600 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2963 {
2964
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 318 times.
587 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2965 269 }
2966
2967
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2968 {
2969
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2970 82 }
2971
2972
4/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2973 {
2974
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 163 times.
119 set_qr(qr_STEP_IS_FLOAT,0);
2975 282 }
2976
2977
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if ( tempheader.zelda_version < 0x250 )
2978 {
2979
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2980 82 }
2981
2982
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version < 3)
2983 {
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2985
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2986 82 }
2987
2988
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<4)
2989 {
2990
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2991 82 }
2992
2993
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<5)
2994 {
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2996 82 }
2997
2998
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<6)
2999 {
3000
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3001 82 }
3002
3003
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<7) // January 2008
3004 {
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3006
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3007 82 }
3008
3009
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<8)
3010 {
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3012 82 }
3013 else
3014 {
3015
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 set_bit(deprecated_rules, 12, 0);
3016 }
3017
3018
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<9) // October 2008
3019 {
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3021
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3022
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3023
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3024 82 }
3025
3026
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<10) // December 2008
3027 {
3028
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3029
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3030 82 }
3031
3032
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<11) // April 2009
3033 {
3034
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3035 82 }
3036
3037 // This served no purpose.
3038 // if(s_version<12) // December 2009
3039 // {
3040 // set_qr(qr_BRKBLSHLDS_DEP,0);
3041 // set_qr(qr_OLDTRIBBLES_DEP,0);
3042 // }
3043
3044 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3045
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version < 13)
3046 {
3047
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3048 82 }
3049
3050 // Not entirely sure this is the best place for this...
3051 //2.50.2 bitmap offset fix
3052 497 memset(extra_rules, 0, EXTRARULES_SIZE);
3053
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
497 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3054 {
3055
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3056
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3057 143 }
3058 //required because quest templates also used this bit, although
3059 //it never did anything, before. -Z
3060
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 158 times.
358 if ( tempheader.zelda_version == 0x250 )
3061 {
3062
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3063 {
3064
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3065
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3066 97 }
3067 200 }
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 if ( tempheader.zelda_version == 0x254 )
3069 {
3070 set_er(er_BITMAPOFFSET, 0);
3071 set_qr(qr_BITMAPOFFSETFIX, 0);
3072 }
3073
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 143 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
358 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3074 {
3075 set_er(er_BITMAPOFFSET, 0);
3076 set_qr(qr_BITMAPOFFSETFIX, 0);
3077 }
3078 //optimise fast drawing for older versions.
3079
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
358 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3080 {
3081
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 120 times.
358 set_qr(qr_OLDSPRITEDRAWS, 1);
3082 282 }
3083 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3084 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3085 //older quests can set the rule by hand. We need a new qst.dat again.
3086
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3087 {
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDEWPNPARENT, 1);
3089 }
3090
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3091 {
3092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3093 }
3094
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3095 {
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDQUESTMISC, 1);
3097 }
3098
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3099 {
3100
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3101
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3102
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3103 282 }
3104
3105 //item scripts continue to run
3106
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3107 {
3108
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3109
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3110
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3111
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3112
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3113
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3114
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3115 282 }
3116
3117
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3118 {
3119
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3120 282 }
3121
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3122 {
3123
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_TRACESCRIPTIDS, 0);
3124
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3125
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3126
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3127
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3128
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3129
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3130
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3131
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3132 {
3133
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3134 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3135 //Now they **do**, unless you disable that behaviour.
3136 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3137 //now enable the disable L/R item swap on load.
3138 8 }
3139
3140 282 }
3141
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3142 {
3143 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3144
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3145 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3146 //animations ending earlier than they should.
3147
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3148 //Enemies would ignore solidity on the top half of combos
3149
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3150 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3151
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3152 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3153
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3154 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3155
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3156 282 }
3157
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3158 {
3159
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3160
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3161
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3162
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3163 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3164 282 }
3165
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3166 {
3167
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3168 282 }
3169
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3170 {
3171
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_OLD_PRINTF_ARGS, 1);
3172 282 }
3173
3174
3175
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3176 {
3177
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_BROKEN_RING_POWER, 1);
3178 282 }
3179
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3180 {
3181
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3182 282 }
3183
5/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163 times.
✓ Branch 5 taken 52 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3184 {
3185
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3186 282 }
3187
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
334 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3188 {
3189 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
334 if(get_qr(qr_SET_XBUTTON_ITEMS))
3191 set_qr(qr_SET_YBUTTON_ITEMS,1);
3192 282 }
3193
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3194 {
3195
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3196 282 }
3197
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3198 {
3199
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_OLD_CHEST_COLLISION,1);
3200 282 }
3201
3202
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3203 {
3204
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3205 282 }
3206 //Sideview spikes in 2.50.0
3207
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3208 {
3209
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 196 times.
333 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3210 137 }
3211 //more 2.50 fixes -Z
3212
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3213 {
3214
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 69 times.
263 set_qr(qr_MELEEMAGICCOST, 0);
3215
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3216
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3217
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3218
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3219
3220 224 }
3221
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
439 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3222 {
3223 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3224 set_qr(qr_MELEEMAGICCOST, 1);
3225 }
3226
3227
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 416 times.
439 if(tempheader.zelda_version < 0x193)
3228 {
3229
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3230 23 }
3231
3232
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 157 times.
439 if(tempheader.zelda_version < 0x255)
3233 {
3234
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3235 282 }
3236
3237
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 357 times.
439 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3238 {
3239
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3240 82 }
3241
3242
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
439 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3243 {
3244
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 157 times.
439 set_qr(qr_OLD_F6,1);
3245 282 }
3246
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3247 {
3248
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3249 282 }
3250
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3251 {
3252
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3253 282 }
3254
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3255 {
3256
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3257 282 }
3258 //}
3259
3260
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3261
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3262
3263
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3264
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3265
3266
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3267
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3268
3269
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3270
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3271
3272
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3273
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3274
3275
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3276
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3277
3278
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3279
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3280
3281
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3282
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3283
3284
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3285 {
3286 //Hardcoded BS Patras
3287
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3288 //Hardcoded Patra Inner Eye offsets
3289
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3290 //Broken 'Big enemy' animation style
3291
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3292 //Broken Attribute 31/32
3293
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3294 282 }
3295
3296
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3297
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3298
3299
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3300
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3301
3302
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3303 {
3304 //Old fire trail duration
3305
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3306 //Old Intro String in Ganon Room Behavior
3307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3308
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3309 282 }
3310
3311
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3312 set_qr(qr_ANONE_NOANIM,1);
3313
3314
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3315
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3316
3317
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3318
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3319
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3321
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3322
3323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3324 {
3325 //Old Quake/DrawYOffset behavior
3326 //set_qr(qr_OLD_DRAWOFFSET,1);
3327 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3328 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3329 282 }
3330
3331
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3332 {
3333 //Broken DrawScreen Derivative Functions
3334
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3335 //Scrolling Cancels Charge
3336
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3337 282 }
3338
3339
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3340
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3341
3342
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3343
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3344
3345
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3346 {
3347
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3348
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3349
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3350
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3351
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3352 282 }
3353
3354
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3355
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3356
3357
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3358
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3359
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3361 {
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3363
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3364 282 }
3365
3366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3367 {
3368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3369
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3370
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3371 282 }
3372
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3373 {
3374
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3375
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3376
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3377 282 }
3378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3379 {
3380
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3381
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3382
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3383
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3384 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3385 282 }
3386
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3387
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3388
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3389
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3390
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3391 {
3392
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3393
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3394 287 }
3395
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3396 {
3397
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3398
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3399 287 }
3400
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3401
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3402
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3403
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3404
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3405 {
3406
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3407
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3408
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3409
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3410 287 }
3411
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 35)
3412 {
3413
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3414
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3415 289 }
3416
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 36)
3417
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3418
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 37)
3419
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3420
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 38)
3421
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3422
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 39)
3423
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3424
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 40)
3425
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3426
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 41)
3427
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3428
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3429
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3430
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3431
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3432
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3433
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3434
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3435
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3436
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3437
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3438
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 47)
3439 {
3440
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3441
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3442 299 }
3443
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 48)
3444
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3445
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 49)
3446
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3447
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 50)
3448
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3449
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 51)
3450
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3451
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if (compatrule_version < 52)
3452
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3453
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 53)
3454 {
3455
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3456
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3457
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3458 299 }
3459
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 54)
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3461
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 55)
3462
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3463
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 56)
3464
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3465
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 57)
3466
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3467
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 58)
3468
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3469
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 59)
3470
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3471
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 60)
3472
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3473
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 61)
3474
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3475
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 62)
3476
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3477
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 63)
3478 {
3479
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3480
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3481 300 }
3482
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 64)
3483
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3484
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 21 times.
304 if(compatrule_version < 65)
3485
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3486
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 66)
3487
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3488
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 67)
3489
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3490
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 68)
3491
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3492
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 69)
3493
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3494
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 70)
3495
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_CONVEYORS, 1);
3496
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 71)
3497
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3498
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 72)
3499
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3500
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 73)
3501 {
3502
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_OLD_LANDING_SFX, 1);
3503
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3504 328 }
3505
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
346 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3506
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3507
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
673 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3508
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3509
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 672 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1000 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3510
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3511
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 77)
3512
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3513
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 78)
3514
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3515
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 79)
3516
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3517
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 80)
3518
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3519
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 993 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1327 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3520
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3521
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1320 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1654 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3522
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3523
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1647 times.
1981 if (compatrule_version < 82)
3524 {
3525
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3526
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3527 334 }
3528
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1647 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1981 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3529
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3530
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1974 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2308 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3531
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3532
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 2301 times.
2635 if (compatrule_version < 85)
3533
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3534
5/6
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2291 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2635 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3535
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 327 times.
17 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3536
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 87)
3537
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3538
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 88)
3539
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3540
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 89)
3541
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3542
3543
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 90)
3544 {
3545
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3546
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3547 344 }
3548
3549
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2616 times.
2962 if (compatrule_version < 91)
3550 {
3551
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_INTERNAL_ARRAYS_BOUND_INDEX, 1);
3552
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_ARRAYS_NON_ZERO_DEFAULT_VALUE, 1);
3553 346 }
3554
3555
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2616 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2962 if (compatrule_version < 92 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3556
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 327 times.
19 set_qr(qr_OLD_PIT_SENSITIVITY, 1);
3557
3558
5/6
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 2925 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
3289 if (compatrule_version < 93 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 12) < 0))
3559
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 327 times.
37 set_qr(qr_ACTIVE_SHIELD_PASSIVE_ROC_NO_SCRIPT, 1);
3560
3561
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 94)
3562
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_OLD_SCRIPTS_MESSAGE_DATA_BINARY_ENCODING, 1);
3563
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 95)
3564
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_ONLY_MARK_SCREENS_VISITED_IF_MAP_VIEWABLE, 1);
3565
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 96)
3566
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_ACTIVE_SUB_IGNORE_8PX, 1);
3567
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 97)
3568 {
3569
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_DRAWCOMBO_IGNORES_FRAME, 1);
3570
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY, 1);
3571 364 }
3572
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 98)
3573
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_BUGGY_MULTIPLE_WIND, 1);
3574
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 99)
3575
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_NO_DEATH_EVENTS_FOR_SEGMENTED_ENEMY_CORES, 1);
3576
3577
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 3119 times.
3616 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3578
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 215 times.
497 if (s_version < 16)
3579
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3580
3581
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 *Header = tempheader;
3582
3583 497 return 0;
3584 22681 }
3585
3586 4224104 void init_msgstr(MsgStr *str)
3587 {
3588
2/4
✓ Branch 0 taken 4224104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4224104 times.
4224104 str->setFromLegacyEncoding("");
3589 4224104 str->nextstring=0;
3590 4224104 str->tile=0;
3591 4224104 str->cset=0;
3592 4224104 str->trans=false;
3593 4224104 str->font=font_zfont;
3594 4224104 str->y=32;
3595 4224104 str->sfx=18;
3596 4224104 str->listpos=0;
3597 4224104 str->x=24;
3598 4224104 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3599 4224104 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3600 4224104 str->hspace=0;
3601 4224104 str->vspace=0;
3602 4224104 str->stringflags=0;
3603 4224104 str->margins[up] = 8;
3604 4224104 str->margins[down] = 0;
3605 4224104 str->margins[left] = 8;
3606 4224104 str->margins[right] = 8;
3607 4224104 str->portrait_tile = 0;
3608 4224104 str->portrait_cset = 0;
3609 4224104 str->portrait_x = 0;
3610 4224104 str->portrait_y = 0;
3611 4224104 str->portrait_tw = 1;
3612 4224104 str->portrait_th = 1;
3613 4224104 str->shadow_type = 0;
3614 4224104 str->shadow_color = 0;
3615 4224104 str->drawlayer = 6;
3616 4224104 }
3617
3618 497 void init_msgstrings(int32_t start, int32_t end)
3619 {
3620
2/4
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
497 if(end <= start || end-start > msg_strings_size)
3621 return;
3622
3623
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 4071424 times.
4071921 for(int32_t i=start; i<end; i++)
3624 {
3625 4071424 init_msgstr(&MsgStrings[i]);
3626 4071424 MsgStrings[i].listpos=i;
3627 4071424 }
3628
3629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(start==0)
3630 {
3631
2/4
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
497 MsgStrings[0].setFromLegacyEncoding("(None)");
3632 497 MsgStrings[0].listpos = 0;
3633 497 }
3634 497 }
3635
3636 498 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3637 {
3638
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3639
3640 498 MsgStr tempMsgString;
3641
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 init_msgstr(&tempMsgString);
3642
3643 498 word temp_msg_count=0;
3644 word temp_expansion[16];
3645 498 memset(temp_expansion, 0, 16*sizeof(word));
3646 498 char buf[8193] = {0};
3647
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(Header->zelda_version < 0x193)
3648 {
3649 byte tempbyte;
3650 24 int32_t strings_to_read=0;
3651
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3652
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3653
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3654
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3655 {
3656 18 strings_to_read=128;
3657 18 temp_msg_count=Header->old_str_count;
3658
3659 // Some sort of string count corruption seems to be common in old quests
3660
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3661 {
3662 temp_msg_count=128;
3663 }
3664 18 }
3665
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3666 {
3667 strings_to_read=255;
3668 temp_msg_count=Header->old_str_count;
3669 }
3670 else
3671 {
3672
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3673 {
3674 return qe_invalid;
3675 }
3676
3677 6 strings_to_read=temp_msg_count;
3678
3679
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3680 {
3681 Z_message("Reallocating string buffer...\n");
3682
3683 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3684 // return qe_nomem;
3685
3686 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3687 delete[] MsgStrings;
3688 MsgStrings = new MsgStr[MAXMSGS];
3689 msg_strings_size = MAXMSGS;
3690 for(auto q = 0; q < msg_strings_size; ++q)
3691 {
3692 MsgStrings[q].clear();
3693 }
3694 }
3695 }
3696
3697 //reset the message strings
3698
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3699
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3700
3701
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3702 {
3703
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3704 2550 tempMsgString.listpos = x;
3705
3706
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3707 {
3708 return qe_invalid;
3709 }
3710
3711 2550 buf[74] = '\0';
3712
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3713
3714
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3715 {
3716 return qe_invalid;
3717 }
3718
3719
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3720
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3721 {
3722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3723
3724
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3725 {
3726 return qe_invalid;
3727 }
3728
3729
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3730 {
3731 return qe_invalid;
3732 }
3733 2304 }
3734 else
3735 {
3736
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3737 {
3738 return qe_invalid;
3739 }
3740
3741
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3742 {
3743 return qe_invalid;
3744 }
3745 }
3746
3747
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3748 {
3749
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3750 2549 }
3751 2550 }
3752 24 }
3753 else
3754 {
3755 int32_t dummy_int;
3756 word s_version;
3757
3758 //section version info
3759
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
3760 {
3761 return qe_invalid;
3762 }
3763
3764
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_STRINGS)
3765 return qe_version;
3766
3767 474 FFCore.quest_format[vStrings] = s_version;
3768
3769
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!read_deprecated_section_cversion(f))
3770 {
3771 return qe_invalid;
3772 }
3773
3774 //section size
3775
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy_int,f))
3776 {
3777 return qe_invalid;
3778 }
3779
3780 //finally... section data
3781
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&temp_msg_count,f))
3782 {
3783 return qe_invalid;
3784 }
3785
3786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
474 if(temp_msg_count >= msg_strings_size && !should_skip)
3787 {
3788 Z_message("Reallocating string buffer...\n");
3789
3790 delete[] MsgStrings;
3791 MsgStrings = new MsgStr[MAXMSGS];
3792 msg_strings_size = MAXMSGS;
3793 for(auto q = 0; q < msg_strings_size; ++q)
3794 {
3795 MsgStrings[q].clear();
3796 }
3797 }
3798
3799 //reset the message strings
3800
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 215 times.
474 if(s_version < 7)
3801
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3802
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (!should_skip)
3803
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 init_msgstrings(0,msg_strings_size);
3804
3805 474 int32_t string_length=(s_version<2)?73:145;
3806
3807
2/2
✓ Branch 0 taken 149632 times.
✓ Branch 1 taken 474 times.
150106 for(int32_t i=0; i<temp_msg_count; i++)
3808 {
3809
1/2
✓ Branch 0 taken 149632 times.
✗ Branch 1 not taken.
149632 init_msgstr(&tempMsgString);
3810
2/2
✓ Branch 0 taken 148502 times.
✓ Branch 1 taken 1130 times.
149632 if (s_version >= 11)
3811 1130 tempMsgString.encoding_type = MsgStr::EncodingType::Ascii;
3812 149632 tempMsgString.listpos = i;
3813
2/2
✓ Branch 0 taken 17706 times.
✓ Branch 1 taken 131926 times.
149632 if(s_version > 8)
3814 {
3815
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_igetl(&string_length,f))
3816 {
3817 return qe_invalid;
3818 }
3819 17706 }
3820
3821
2/4
✓ Branch 0 taken 149632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 149632 times.
149632 if (string_length < 0 || string_length > 8193)
3822 {
3823 return qe_invalid;
3824 }
3825
3826
2/2
✓ Branch 0 taken 144753 times.
✓ Branch 1 taken 4879 times.
149632 if (string_length > 0)
3827 {
3828
2/4
✓ Branch 0 taken 144753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144753 times.
✗ Branch 3 not taken.
144753 if (!pfread(buf, string_length, f))
3829 {
3830 return qe_invalid;
3831 }
3832 144753 }
3833 else
3834 {
3835 4879 buf[0] = 0;
3836 }
3837
3838
2/4
✓ Branch 0 taken 149632 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149632 times.
✗ Branch 3 not taken.
149632 if(!p_igetw(&tempMsgString.nextstring,f))
3839 {
3840 return qe_invalid;
3841 }
3842
3843
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 116019 times.
149632 if(s_version<2)
3844 {
3845 33613 buf[72] = '\0';
3846
2/4
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33613 times.
✗ Branch 3 not taken.
33613 tempMsgString.setFromLegacyEncoding(buf);
3847 33613 }
3848 else
3849 {
3850 // June 2008: A bug corrupted the last 4 chars of a string.
3851 // Discard these.
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116019 times.
116019 if (!should_skip)
3853 {
3854
1/2
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
116019 if(s_version<3)
3855 {
3856 for(int32_t j=140; j<144; j++)
3857 {
3858 buf[j] = '\0';
3859 }
3860 }
3861
1/2
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
116019 if(string_length > 8192) string_length = 8192;
3862 116019 buf[string_length]='\0'; //Force-terminate
3863
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 tempMsgString.set(buf, tempMsgString.encoding_type);
3864 116019 }
3865
3866
2/2
✓ Branch 0 taken 17706 times.
✓ Branch 1 taken 98313 times.
116019 if ( s_version >= 6 )
3867 {
3868
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_igetl(&tempMsgString.tile,f))
3869 {
3870 return qe_invalid;
3871 }
3872 17706 }
3873 else
3874 {
3875
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3876 {
3877 return qe_invalid;
3878 }
3879 }
3880
3881
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.cset,f))
3882 {
3883 return qe_invalid;
3884 }
3885
3886 byte dummy_char;
3887
3888
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3889 {
3890 return qe_invalid;
3891 }
3892
3893 116019 tempMsgString.trans=dummy_char!=0;
3894
3895
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.font,f))
3896 {
3897 return qe_invalid;
3898 }
3899
3900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116019 times.
116019 if(s_version < 5)
3901 {
3902 if(!p_getc(&tempMsgString.y,f))
3903 {
3904 return qe_invalid;
3905 }
3906 }
3907 else
3908 {
3909
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_igetw(&tempMsgString.x,f))
3910 {
3911 return qe_invalid;
3912 }
3913
3914
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_igetw(&tempMsgString.y,f))
3915 {
3916 return qe_invalid;
3917 }
3918
3919
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_igetw(&tempMsgString.w,f))
3920 {
3921 return qe_invalid;
3922 }
3923
3924
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_igetw(&tempMsgString.h,f))
3925 {
3926 return qe_invalid;
3927 }
3928
3929
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.hspace,f))
3930 {
3931 return qe_invalid;
3932 }
3933
3934
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.vspace,f))
3935 {
3936 return qe_invalid;
3937 }
3938
3939
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.stringflags,f))
3940 {
3941 return qe_invalid;
3942 }
3943 }
3944
3945
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 17706 times.
116019 if(s_version >= 7)
3946 {
3947
2/2
✓ Branch 0 taken 17706 times.
✓ Branch 1 taken 70824 times.
88530 for(int32_t q = 0; q < 4; ++q)
3948 {
3949
2/4
✓ Branch 0 taken 70824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70824 times.
✗ Branch 3 not taken.
70824 if(!p_getc(&tempMsgString.margins[q],f))
3950 {
3951 return qe_invalid;
3952 }
3953 70824 }
3954
3955
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_igetl(&tempMsgString.portrait_tile,f))
3956 {
3957 return qe_invalid;
3958 }
3959
3960
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.portrait_cset,f))
3961 {
3962 return qe_invalid;
3963 }
3964
3965
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.portrait_x,f))
3966 {
3967 return qe_invalid;
3968 }
3969
3970
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.portrait_y,f))
3971 {
3972 return qe_invalid;
3973 }
3974
3975
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.portrait_tw,f))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.portrait_th,f))
3981 {
3982 return qe_invalid;
3983 }
3984 17706 }
3985
3986
2/2
✓ Branch 0 taken 17706 times.
✓ Branch 1 taken 98313 times.
116019 if(s_version >= 8)
3987 {
3988
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.shadow_type,f))
3989 {
3990 return qe_invalid;
3991 }
3992
3993
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 if(!p_getc(&tempMsgString.shadow_color,f))
3994 {
3995 return qe_invalid;
3996 }
3997 17706 }
3998
3999
2/2
✓ Branch 0 taken 17397 times.
✓ Branch 1 taken 98622 times.
116019 if(s_version >= 10)
4000 {
4001
2/4
✓ Branch 0 taken 17397 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17397 times.
✗ Branch 3 not taken.
17397 if(!p_getc(&tempMsgString.drawlayer,f))
4002 {
4003 return qe_invalid;
4004 }
4005 17397 }
4006
4007
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_getc(&tempMsgString.sfx,f))
4008 {
4009 return qe_invalid;
4010 }
4011
4012
1/2
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
116019 if(s_version>3)
4013 {
4014
2/4
✓ Branch 0 taken 116019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116019 times.
✗ Branch 3 not taken.
116019 if(!p_igetw(&tempMsgString.listpos,f))
4015 {
4016 return qe_invalid;
4017 }
4018 116019 }
4019 }
4020
4021
1/2
✓ Branch 0 taken 149632 times.
✗ Branch 1 not taken.
149632 if (!should_skip)
4022 {
4023
1/2
✓ Branch 0 taken 149632 times.
✗ Branch 1 not taken.
149632 MsgStrings[i].copyAll(tempMsgString);
4024 149632 }
4025 149632 }
4026 }
4027
4028
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
4029 497 msg_count=temp_msg_count;
4030
4031 498 return 0;
4032 498 }
4033
4034 498 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4035 {
4036
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4037
4038
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
504 if((Header->zelda_version < 0x192)||
4039
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 474 times.
480 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4040 {
4041 18 return 0;
4042 }
4043
4044 480 word temp_door_combo_set_count=0;
4045 DoorComboSet tempDoorComboSet;
4046 word dummy_word;
4047 int32_t dummy_long;
4048 byte padding;
4049 480 int32_t s_version = 0;
4050
4051
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 479 times.
480 if (!should_skip)
4052 {
4053 479 DoorComboSets = {};
4054 479 DoorComboSetNames = {};
4055 479 }
4056
4057
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 474 times.
480 if(Header->zelda_version > 0x192)
4058 {
4059 //section version info
4060
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
4061 {
4062 return qe_invalid;
4063 }
4064
4065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_DOORS)
4066 return qe_version;
4067
4068 474 FFCore.quest_format[vDoors] = s_version;
4069
4070
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&dummy_word,f))
4071 {
4072 return qe_invalid;
4073 }
4074
4075 //section size
4076
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy_long,f))
4077 {
4078 return qe_invalid;
4079 }
4080 474 }
4081
4082 //finally... section data
4083
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_igetw(&temp_door_combo_set_count,f))
4084 {
4085 return qe_invalid;
4086 }
4087
4088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4089 {
4090 return qe_invalid;
4091 }
4092
4093
2/2
✓ Branch 0 taken 5720 times.
✓ Branch 1 taken 480 times.
6200 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4094 {
4095 5720 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4096
4097 //name
4098 char name[21];
4099
1/2
✓ Branch 0 taken 5720 times.
✗ Branch 1 not taken.
5720 if(!pfread(&name,sizeof(name),f))
4100 {
4101 return qe_invalid;
4102 }
4103
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5706 times.
5720 if (!should_skip)
4104 5706 DoorComboSetNames[i] = name;
4105
4106
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4107 {
4108
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4109 {
4110 return qe_invalid;
4111 }
4112 40 }
4113
4114 //up door
4115
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4116 {
4117
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4118 {
4119
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4120 {
4121 return qe_invalid;
4122 }
4123 205920 }
4124 51480 }
4125
4126
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4127 {
4128
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4129 {
4130
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4131 {
4132 return qe_invalid;
4133 }
4134 205920 }
4135 51480 }
4136
4137 //down door
4138
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4139 {
4140
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4141 {
4142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205920 times.
205920 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4143 {
4144 return qe_invalid;
4145 }
4146 205920 }
4147 51480 }
4148
4149
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4150 {
4151
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4152 {
4153
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4154 {
4155 return qe_invalid;
4156 }
4157 205920 }
4158 51480 }
4159
4160 //left door
4161
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4162 {
4163
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4164 {
4165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308880 times.
308880 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4166 {
4167 return qe_invalid;
4168 }
4169 308880 }
4170 51480 }
4171
4172
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4173 {
4174
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4175 {
4176
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4177 {
4178 return qe_invalid;
4179 }
4180 308880 }
4181 51480 }
4182
4183 //right door
4184
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4185 {
4186
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4187 {
4188
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4189 {
4190 return qe_invalid;
4191 }
4192 308880 }
4193 51480 }
4194
4195
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4196 {
4197
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4198 {
4199
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4200 {
4201 return qe_invalid;
4202 }
4203 308880 }
4204 51480 }
4205
4206 //up bomb rubble
4207
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4208 {
4209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4210 {
4211 return qe_invalid;
4212 }
4213 11440 }
4214
4215
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4216 {
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4218 {
4219 return qe_invalid;
4220 }
4221 11440 }
4222
4223 //down bomb rubble
4224
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4225 {
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4227 {
4228 return qe_invalid;
4229 }
4230 11440 }
4231
4232
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4233 {
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4235 {
4236 return qe_invalid;
4237 }
4238 11440 }
4239
4240 //left bomb rubble
4241
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4242 {
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4244 {
4245 return qe_invalid;
4246 }
4247 17160 }
4248
4249
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4250 {
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4252 {
4253 return qe_invalid;
4254 }
4255 17160 }
4256
4257
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4258 {
4259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4260 {
4261 return qe_invalid;
4262 }
4263
4264 40 }
4265
4266 //right bomb rubble
4267
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4268 {
4269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4270 {
4271 return qe_invalid;
4272 }
4273 17160 }
4274
4275
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4276 {
4277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4278 {
4279 return qe_invalid;
4280 }
4281 17160 }
4282
4283
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4284 {
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4286 {
4287 return qe_invalid;
4288 }
4289 40 }
4290
4291 //walkthrough stuff
4292
2/2
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 5720 times.
28600 for(int32_t j=0; j<4; j++)
4293 {
4294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22880 times.
22880 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4295 {
4296 return qe_invalid;
4297 }
4298 22880 }
4299
4300
2/2
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 5720 times.
28600 for(int32_t j=0; j<4; j++)
4301 {
4302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22880 times.
22880 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4303 {
4304 return qe_invalid;
4305 }
4306 22880 }
4307
4308 //flags
4309
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4310 {
4311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.flags[j],f))
4312 {
4313 return qe_invalid;
4314 }
4315 11440 }
4316
4317
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4320 {
4321 return qe_invalid;
4322 }
4323 40 }
4324
4325
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5706 times.
5720 if (!should_skip)
4326 5706 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4327 5720 }
4328
4329
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 479 times.
480 if (!should_skip)
4330 479 door_combo_set_count=temp_door_combo_set_count;
4331
4332 480 return 0;
4333 498 }
4334
4335 9 int32_t count_dmaps()
4336 {
4337 9 int32_t i=MAXDMAPS-1;
4338 9 bool found=false;
4339
4340
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4341 {
4342
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4343
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4344
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4345 18 found=true;
4346
4347
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4348 {
4349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4350
4351 found=true;
4352 72 }
4353
4354
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4355 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4356 27 found=true;
4357
4358
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4359
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4360
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4361
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4362 18 found=true;
4363
4364 if(!found)
4365 {
4366 i--;
4367 }
4368 }
4369
4370 9 return i+1;
4371 }
4372
4373
4374 9 int32_t count_shops(miscQdata *Misc)
4375 {
4376 9 int32_t i=NUM_SHOPS-1,j;
4377 9 bool found=false;
4378
4379
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4380 {
4381 2229 j=2;
4382
4383
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4384 {
4385
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4386 {
4387 5 found=true;
4388 5 }
4389 else
4390 {
4391 6672 j--;
4392 }
4393 }
4394
4395
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4396 {
4397 found=true;
4398 }
4399
4400
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4401 {
4402 2224 i--;
4403 2224 }
4404 }
4405
4406 9 return i+1;
4407 }
4408
4409 9 int32_t count_infos(miscQdata *Misc)
4410 {
4411 9 int32_t i=255,j;
4412 9 bool found=false;
4413
4414
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4415 {
4416 2229 j=2;
4417
4418
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4419 {
4420
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4421 {
4422 5 found=true;
4423 5 }
4424 else
4425 {
4426 6672 j--;
4427 }
4428 }
4429
4430
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4431 {
4432 found=true;
4433 }
4434
4435
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4436 {
4437 2224 i--;
4438 2224 }
4439 }
4440
4441 9 return i+1;
4442 }
4443
4444 9 int32_t count_warprings(miscQdata *Misc)
4445 {
4446 9 int32_t i=15,j;
4447 9 bool found=false;
4448
4449
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4450 {
4451 49 j=7;
4452
4453
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4454 {
4455
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4456 {
4457 9 found=true;
4458 9 }
4459 else
4460 {
4461 349 j--;
4462 }
4463 }
4464
4465
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4466 {
4467 40 i--;
4468 40 }
4469 }
4470
4471 9 return i+1;
4472 }
4473
4474 9 int32_t count_palcycles(miscQdata *Misc)
4475 {
4476 9 int32_t i=255,j;
4477 9 bool found=false;
4478
4479
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4480 {
4481 2036 j=2;
4482
4483
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4484 {
4485
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4486 {
4487 7 found=true;
4488 7 }
4489 else
4490 {
4491 6087 j--;
4492 }
4493 }
4494
4495
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4496 {
4497 2029 i--;
4498 2029 }
4499 }
4500
4501 9 return i+1;
4502 }
4503
4504 192168 void clear_screen(mapscr *temp_scr)
4505 {
4506 192168 temp_scr->zero_memory();
4507 192168 }
4508
4509 // NOTE: when modifying this, you need to also update:
4510 // readdmaps, and FFScript::read_dmaps
4511 // (and their associated write functions)
4512
4513 232768 int32_t read_one_dmap(PACKFILE* f, zquestheader *Header, int s_version, int index)
4514 {
4515
2/2
✓ Branch 0 taken 230656 times.
✓ Branch 1 taken 2112 times.
232768 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4516 232768 dmap tempDMap;
4517 char legacy_title[22];
4518 byte padding;
4519
4520
2/2
✓ Branch 0 taken 229440 times.
✓ Branch 1 taken 3328 times.
232768 if (!should_skip)
4521 {
4522
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 DMaps[index].clear();
4523 229440 DMaps[index].type |= dmCAVE;
4524 229440 }
4525
4526 {
4527
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 3072 times.
232768 tempDMap.clear();
4528 229696 sprintf(legacy_title," ");
4529 229696 sprintf(tempDMap.intro," ");
4530
4531
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.map,f))
4532 {
4533 return qe_invalid;
4534 }
4535
4536
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 212480 times.
229696 if(s_version <= 4)
4537 {
4538 byte tempbyte;
4539
4540
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4541 {
4542 return qe_invalid;
4543 }
4544
4545 17216 tempDMap.level=(word)tempbyte;
4546 17216 }
4547 else
4548 {
4549
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetw(&tempDMap.level,f))
4550 {
4551 return qe_invalid;
4552 }
4553 }
4554
4555
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.xoff,f))
4556 {
4557 return qe_invalid;
4558 }
4559
4560
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.compass,f))
4561 {
4562 return qe_invalid;
4563 }
4564
4565
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version > 8) // February 2009
4566 {
4567
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetw(&tempDMap.color,f))
4568 {
4569 return qe_invalid;
4570 }
4571 212480 }
4572 else
4573 {
4574 byte tempbyte;
4575
4576
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4577 {
4578 return qe_invalid;
4579 }
4580
4581 17216 tempDMap.color = (word)tempbyte;
4582 }
4583
4584
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.midi,f))
4585 {
4586 return qe_invalid;
4587 }
4588
4589
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.cont,f))
4590 {
4591 return qe_invalid;
4592 }
4593
4594
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.type,f))
4595 {
4596 return qe_invalid;
4597 }
4598
4599
4/4
✓ Branch 0 taken 6353 times.
✓ Branch 1 taken 223343 times.
✓ Branch 2 taken 6309 times.
✓ Branch 3 taken 44 times.
236049 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4600
1/2
✓ Branch 0 taken 6353 times.
✗ Branch 1 not taken.
6353 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4601 6309 tempDMap.xoff = 0;
4602
4603
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 1837568 times.
2067264 for(int32_t j=0; j<8; j++)
4604 {
4605
2/4
✓ Branch 0 taken 1837568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1837568 times.
✗ Branch 3 not taken.
1837568 if(!p_getc(&tempDMap.grid[j],f))
4606 {
4607 return qe_invalid;
4608 }
4609 1837568 }
4610
4611
5/6
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 227584 times.
229696 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4612 {
4613
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4614 {
4615 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4616 127 }
4617
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4618
4619
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(index==0 && Header->zelda_version <= 0x190)
4620 {
4621
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4622
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4623 18 }
4624
4625 //forgotten -DD
4626
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4627 {
4628 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4629 439 }
4630 576 }
4631 else
4632 {
4633
3/4
✓ Branch 0 taken 229120 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
227584 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4634 {
4635 return qe_invalid;
4636 }
4637
4638
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 101376 times.
229120 if(s_version<20)
4639 {
4640
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4641 {
4642 return qe_invalid;
4643 }
4644
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4645 127744 }
4646 else
4647 {
4648
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_getwstr(&tempDMap.title, f))
4649 {
4650 return qe_invalid;
4651 }
4652 }
4653
4654
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4655 {
4656 return qe_invalid;
4657 }
4658
4659
5/8
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 227584 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
229120 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4660 {
4661 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4662 DMaps[index] = tempDMap;
4663
4664 return 0;
4665 }
4666
4667
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4668 {
4669
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4670 {
4671 return qe_invalid;
4672 }
4673 1536 }
4674
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4675 {
4676
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4677 {
4678 return qe_invalid;
4679 }
4680 110080 }
4681 else
4682 {
4683
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4684 {
4685 return qe_invalid;
4686 }
4687 }
4688
4689
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.minimap_cset[0],f))
4690 {
4691 return qe_invalid;
4692 }
4693
4694
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4695 {
4696
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4697 {
4698 return qe_invalid;
4699 }
4700 1536 }
4701
4702
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4703 {
4704
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4705 {
4706 return qe_invalid;
4707 }
4708 110080 }
4709 else
4710 {
4711
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4712 {
4713 return qe_invalid;
4714 }
4715 }
4716
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.minimap_cset[1],f))
4717 {
4718 return qe_invalid;
4719 }
4720
4721
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4722 {
4723
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4724 {
4725 return qe_invalid;
4726 }
4727 1536 }
4728
4729
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4730 {
4731
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4732 {
4733 return qe_invalid;
4734 }
4735 110080 }
4736 else
4737 {
4738
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4739 {
4740 return qe_invalid;
4741 }
4742 }
4743
4744
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.largemap_cset[0],f))
4745 {
4746 return qe_invalid;
4747 }
4748
4749
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4750 {
4751
4752
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4753 {
4754 return qe_invalid;
4755 }
4756 1536 }
4757
4758
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4759 {
4760
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4761 {
4762 return qe_invalid;
4763 }
4764 110080 }
4765 else
4766 {
4767
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4768 {
4769 return qe_invalid;
4770 }
4771 }
4772
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.largemap_cset[1],f))
4773 {
4774 return qe_invalid;
4775 }
4776
4777
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4778 {
4779 return qe_invalid;
4780 }
4781 }
4782
4783
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version>1)
4784 {
4785
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_getc(&tempDMap.tmusictrack,f))
4786 {
4787 return qe_invalid;
4788 }
4789
4790
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_getc(&tempDMap.active_subscreen,f))
4791 {
4792 return qe_invalid;
4793 }
4794
4795
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_getc(&tempDMap.passive_subscreen,f))
4796 {
4797 return qe_invalid;
4798 }
4799 212480 }
4800
4801
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version>2)
4802 {
4803 byte di[32];
4804
4805
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!pfread(&di, 32, f)) return qe_invalid;
4806
4807
2/2
✓ Branch 0 taken 54394880 times.
✓ Branch 1 taken 212480 times.
54607360 for(int32_t j=0; j<MAXITEMS; j++)
4808 {
4809
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 54385673 times.
54394880 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4810 54385673 else tempDMap.disableditems[j]=0;
4811 54394880 }
4812 212480 }
4813
4814
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version >= 6)
4815 {
4816
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetl(&tempDMap.flags,f))
4817 {
4818 return qe_invalid;
4819 }
4820 212480 }
4821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4822 {
4823 char temp;
4824
4825 if(!p_getc(&temp,f))
4826 {
4827 return qe_invalid;
4828 }
4829
4830 tempDMap.flags = temp;
4831 }
4832
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4833 {
4834 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4835 8992 }
4836 else
4837 8224 tempDMap.flags=0;
4838
4839
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version<7)
4840 {
4841
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4842 6146 tempDMap.flags|= dmfVIEWMAP;
4843 17216 }
4844
4845
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version<8)
4846 {
4847
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4848 {
4849
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4850 8050 tempDMap.type |= dmCAVE;
4851 8050 }
4852
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4853 {
4854 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4855 2332 }
4856 17216 }
4857
4858
7/8
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 227584 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 227584 times.
229696 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4859 229120 && (Header->zelda_version < 0x193))
4860 {
4861
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4862 {
4863 return qe_invalid;
4864 }
4865 1536 }
4866
4867
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 110080 times.
229696 if(s_version >= 10)
4868 {
4869
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_getc(&tempDMap.sideview,f))
4870 {
4871 return qe_invalid;
4872 }
4873 110080 }
4874
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version < 10) tempDMap.sideview = 0;
4875
4876 //Dmap Scripts
4877
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 12)
4878 {
4879
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.script,f))
4880 {
4881 return qe_invalid;
4882 }
4883
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
4884 {
4885
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.initD[q],f))
4886 {
4887 return qe_invalid;
4888 }
4889 880640 }
4890 110080 }
4891
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if ( s_version < 12 )
4892 {
4893 119616 tempDMap.script = 0;
4894
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4895 {
4896 956928 tempDMap.initD[q] = 0;
4897 956928 }
4898 119616 }
4899
4900
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 110080 times.
229696 if(s_version >= 13)
4901 {
4902
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
4903 {
4904
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; w++ )
4905 {
4906
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.initD_label[q][w],f))
4907 {
4908 return qe_invalid;
4909 }
4910 57241600 }
4911 880640 }
4912 110080 }
4913
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if ( s_version < 13 )
4914 {
4915 119616 tempDMap.script = 0;
4916
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4917 {
4918
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4919 62200320 tempDMap.initD_label[q][w] = 0;
4920 956928 }
4921 119616 }
4922
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 14)
4923 {
4924
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.active_sub_script,f))
4925 {
4926 return qe_invalid;
4927 }
4928
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.passive_sub_script,f))
4929 {
4930 return qe_invalid;
4931 }
4932
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; ++q )
4933 {
4934
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.sub_initD[q],f))
4935 {
4936 return qe_invalid;
4937 }
4938 880640 }
4939
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for(int32_t q = 0; q < 8; ++q)
4940 {
4941
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; ++w )
4942 {
4943
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4944 {
4945 return qe_invalid;
4946 }
4947 57241600 }
4948 880640 }
4949 110080 }
4950 else
4951 {
4952 119616 tempDMap.active_sub_script = 0;
4953 119616 tempDMap.passive_sub_script = 0;
4954
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4955 {
4956 956928 tempDMap.sub_initD[q] = 0;
4957
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
4958 62200320 tempDMap.sub_initD_label[q][w] = 0;
4959 956928 }
4960 }
4961
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 15)
4962 {
4963
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.onmap_script,f))
4964 {
4965 return qe_invalid;
4966 }
4967
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; ++q )
4968 {
4969
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4970 {
4971 return qe_invalid;
4972 }
4973 880640 }
4974
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for(int32_t q = 0; q < 8; ++q)
4975 {
4976
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; ++w )
4977 {
4978
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4979 {
4980 return qe_invalid;
4981 }
4982 57241600 }
4983 880640 }
4984 110080 }
4985 else
4986 {
4987 119616 tempDMap.onmap_script = 0;
4988
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4989 {
4990 956928 tempDMap.onmap_initD[q] = 0;
4991
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
4992 {
4993 62200320 tempDMap.onmap_initD_label[q][w] = 0;
4994 62200320 }
4995 956928 }
4996 }
4997
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 16)
4998 {
4999
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.mirrorDMap,f))
5000 {
5001 return qe_invalid;
5002 }
5003 110080 }
5004 else
5005 {
5006 119616 tempDMap.mirrorDMap = -1;
5007 }
5008
5009 // Enhanced music loop points
5010
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
229696 if (s_version >= 18)
5011 {
5012
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5013 {
5014 return qe_invalid;
5015 }
5016
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5017 {
5018 return qe_invalid;
5019 }
5020
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5021 {
5022 return qe_invalid;
5023 }
5024
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5025 {
5026 return qe_invalid;
5027 }
5028 101376 }
5029 else
5030 {
5031 128320 tempDMap.tmusic_loop_start = 0;
5032 128320 tempDMap.tmusic_loop_end = 0;
5033 128320 tempDMap.tmusic_xfade_in = 0;
5034 128320 tempDMap.tmusic_xfade_out = 0;
5035 }
5036
5037
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
229696 if(s_version >= 19)
5038
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_getc(&tempDMap.overlay_subscreen, f))
5039 return qe_invalid;
5040
5041
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
229696 if (s_version >= 20)
5042 {
5043
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.intro_string_id, f))
5044 return qe_invalid;
5045 101376 }
5046 else
5047 128320 tempDMap.intro_string_id = 0;
5048
5049
2/2
✓ Branch 0 taken 214848 times.
✓ Branch 1 taken 14848 times.
229696 if(s_version == 21)
5050 {
5051 static regions_data tmp_rd;
5052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5053
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t j=0; j<8; j++)
5054 {
5055
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 118784 times.
1069056 for(int32_t k=0; k<8; k++)
5056 {
5057
2/4
✓ Branch 0 taken 950272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 950272 times.
✗ Branch 3 not taken.
950272 if(!p_getc(&rd.region_ids[j][k],f))
5058 {
5059 return qe_invalid;
5060 }
5061 950272 }
5062 118784 }
5063 14848 }
5064
5065
3/4
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 151360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78336 times.
229696 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5066 {
5067 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5068 return qe_invalid;
5069 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5070 return qe_invalid;
5071 }
5072
2/2
✓ Branch 0 taken 68096 times.
✓ Branch 1 taken 161600 times.
229696 if(s_version > 23)
5073 {
5074
2/4
✓ Branch 0 taken 68096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68096 times.
✗ Branch 3 not taken.
68096 if(!p_igetw(&tempDMap.map_subscreen, f))
5075 return qe_invalid;
5076
2/4
✓ Branch 0 taken 68096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68096 times.
✗ Branch 3 not taken.
68096 if(!p_getc(&tempDMap.floor, f))
5077 return qe_invalid;
5078 68096 }
5079
5080
2/2
✓ Branch 0 taken 229440 times.
✓ Branch 1 taken 256 times.
229696 if (!should_skip)
5081 {
5082
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 if(loading_tileset_flags & TILESET_CLEARMAPS)
5083 tempDMap.map = 0;
5084
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5085 {
5086 tempDMap.script = 0;
5087 for(int q = 0; q < 8; ++q)
5088 tempDMap.initD[q] = 0;
5089 }
5090
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 DMaps[index] = tempDMap;
5091 229440 }
5092 }
5093 229696 return 0;
5094 235840 }
5095 498 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
5096 {
5097
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
5098
5099 498 word dmapstoread=0;
5100
5101 int32_t dummy;
5102 498 word s_version=0;
5103
5104
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 497 times.
✗ Branch 3 not taken.
498 if (!should_skip && s_version == 21)
5105 Regions = {};
5106
5107 498 Header->is_z3 = false;
5108
3/4
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 24 times.
498 if(!Header || Header->zelda_version > 0x192)
5109 {
5110 //section version info
5111
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
5112 {
5113 return qe_invalid;
5114 }
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_DMAPS)
5117 return qe_version;
5118
5119 474 Header->is_z3 = s_version >= 22;
5120 474 FFCore.quest_format[vDMaps] = s_version;
5121
5122
5123
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
5124 {
5125 return qe_invalid;
5126 }
5127
5128 //section size
5129
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
5130 {
5131 return qe_invalid;
5132 }
5133
5134 //finally... section data
5135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(!p_igetw(&dmapstoread,f))
5136 {
5137 return qe_invalid;
5138 }
5139 474 }
5140 else
5141 {
5142
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5143
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
5144 {
5145 18 dmapstoread=32;
5146 18 }
5147
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
5148 {
5149 6 dmapstoread=OLDMAXDMAPS;
5150 6 }
5151 else
5152 {
5153 dmapstoread=MAXDMAPS;
5154 }
5155 }
5156
5157
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 415 times.
498 dmapstoread = zc_min(dmapstoread, max_dmaps);
5158
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 415 times.
498 dmapstoread = zc_min(dmapstoread, MAXDMAPS-start_dmap);
5159
5160
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 498 times.
230194 for(int i = start_dmap; i < dmapstoread + start_dmap; ++i)
5161 {
5162
1/2
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
229696 if (int ret = read_one_dmap(f, Header, s_version, i))
5163 return ret;
5164 229696 }
5165
5166 498 return 0;
5167 498 }
5168
5169 415 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5170 {
5171 //these are here to bypass compiler warnings about unused arguments
5172 415 Header=Header;
5173
5174 415 miscQdata temp_misc;
5175 415 word s_version=0;
5176 415 int32_t tempsize=0;
5177 word dummyw;
5178
5179
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 temp_misc = *Misc;
5180
5181 //section version info
5182
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetw(&s_version,f))
5183 {
5184 return qe_invalid;
5185 }
5186
5187
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if (s_version > V_COLORS)
5188 return qe_version;
5189
5190 415 FFCore.quest_format[vColours] = s_version;
5191
5192
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 al_trace("Misc Colours section version: %d\n", s_version);
5193
5194
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!read_deprecated_section_cversion(f))
5195 {
5196 return qe_invalid;
5197 }
5198
5199
5200 //section size
5201
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetl(&tempsize,f))
5202 {
5203 return qe_invalid;
5204 }
5205
5206 //finally... section data
5207 415 readsize=0;
5208
5209
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.text,f))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.caption,f))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.overw_bg,f))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.cave_fg,f))
5235 {
5236 return qe_invalid;
5237 }
5238
5239
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bs_dk,f))
5240 {
5241 return qe_invalid;
5242 }
5243
5244
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bs_goal,f))
5245 {
5246 return qe_invalid;
5247 }
5248
5249
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.compass_lt,f))
5250 {
5251 return qe_invalid;
5252 }
5253
5254
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.compass_dk,f))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triframe_color,f))
5265 {
5266 return qe_invalid;
5267 }
5268
5269
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.hero_dot,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5285 {
5286 return qe_invalid;
5287 }
5288
5289
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5300 {
5301 return qe_invalid;
5302 }
5303
5304
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5305 {
5306 return qe_invalid;
5307 }
5308
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version < 4)
5309 {
5310
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5311 return qe_invalid;
5312 200 temp_misc.colors.triforce_tile = dummyw;
5313
5314
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5315 return qe_invalid;
5316 200 temp_misc.colors.triframe_tile = dummyw;
5317
5318
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5319 return qe_invalid;
5320 200 temp_misc.colors.overworld_map_tile = dummyw;
5321
5322
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5323 return qe_invalid;
5324 200 temp_misc.colors.dungeon_map_tile = dummyw;
5325
5326
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5327 return qe_invalid;
5328 200 temp_misc.colors.blueframe_tile = dummyw;
5329
5330
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5331 return qe_invalid;
5332 200 temp_misc.colors.HCpieces_tile = dummyw;
5333 200 }
5334
5335
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 2)
5346 {
5347 temp_misc.colors.msgtext = 0x01;
5348 }
5349 else
5350 {
5351
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.msgtext, f))
5352 {
5353 return qe_invalid;
5354 }
5355 }
5356
5357
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 3 ) //expanded tile pages to 825
5358 {
5359
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5365 {
5366 return qe_invalid;
5367 }
5368
5369
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5370 {
5371 return qe_invalid;
5372 }
5373
5374
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5375 {
5376 return qe_invalid;
5377 }
5378
5379
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5380 {
5381 return qe_invalid;
5382 }
5383
5384
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5385 {
5386 return qe_invalid;
5387 }
5388 215 }
5389
5390
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 *Misc = temp_misc;
5391
5392 415 return 0;
5393 415 }
5394
5395 415 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5396 {
5397 415 miscQdata temp_misc;
5398 415 word s_version=0;
5399 byte icons;
5400 415 int32_t tempsize=0;
5401
5402
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 temp_misc = *Misc;
5403
5404 //section version info
5405
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetw(&s_version,f))
5406 {
5407 return qe_invalid;
5408 }
5409
5410
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if (s_version > V_ICONS)
5411 return qe_version;
5412
5413 415 FFCore.quest_format[vIcons] = s_version;
5414
5415
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!read_deprecated_section_cversion(f))
5416 {
5417 return qe_invalid;
5418 }
5419
5420
5421 //section size
5422
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetl(&tempsize,f))
5423 {
5424 return qe_invalid;
5425 }
5426
5427 //finally... section data
5428 415 readsize=0;
5429
5430 415 icons=4;
5431
5432
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 10 )
5433 {
5434
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<icons; i++)
5435 {
5436
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&temp_misc.icons[i],f))
5437 {
5438 return qe_invalid;
5439 }
5440 860 }
5441 215 }
5442 else
5443 {
5444
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5445 {
5446
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&temp_misc.icons[i],f))
5447 {
5448 return qe_invalid;
5449 }
5450 800 }
5451 }
5452
5453
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 *Misc = temp_misc;
5454
5455 415 return 0;
5456 415 }
5457
5458 1420 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5459 {
5460
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 24 times.
1420 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5461
5462 1420 word maxinfos=256;
5463 1420 word maxshops=256;
5464 1420 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5465 1420 word ponds=16, pondsize=72, expansionsize=98*2;
5466 byte tempbyte, padding;
5467 1420 miscQdata temp_misc;
5468 1420 word s_version=0;
5469 word swaptmp;
5470 1420 int32_t tempsize=0;
5471
5472
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 588 times.
1420 temp_misc = *Misc;
5473
5474
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxshops; ++i)
5475 {
5476 212992 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5477 212992 }
5478
5479
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxinfos; ++i)
5480 {
5481 212992 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5482 212992 }
5483
5484 832 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5485
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 832 times.
27456 for (auto& sm : temp_misc.save_menus)
5486
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 sm.clear();
5487
5488
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5489 {
5490 //section version info
5491
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&s_version,f))
5492 {
5493 return qe_invalid;
5494 }
5495
5496
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (s_version > V_MISC)
5497 return qe_version;
5498
5499 808 FFCore.quest_format[vMisc] = s_version;
5500
5501
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!read_deprecated_section_cversion(f))
5502 {
5503 return qe_invalid;
5504 }
5505
5506
5507 //section size
5508
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&tempsize,f))
5509 {
5510 return qe_invalid;
5511 }
5512 808 }
5513
5514 //finally... section data
5515 832 readsize=0;
5516
5517 //shops
5518
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5519 {
5520
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&shops,f))
5521 {
5522 return qe_invalid;
5523 }
5524 808 }
5525
5526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (shops > NUM_SHOPS)
5527 {
5528 return qe_invalid;
5529 }
5530
5531
2/2
✓ Branch 0 taken 11390 times.
✓ Branch 1 taken 832 times.
12222 for(int32_t i=0; i<shops; i++)
5532 {
5533
2/2
✓ Branch 0 taken 10190 times.
✓ Branch 1 taken 1200 times.
11390 if(s_version > 6)
5534 {
5535
2/4
✓ Branch 0 taken 10190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10190 times.
10190 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5536 {
5537 return qe_invalid;
5538 }
5539 10190 }
5540
5541
2/2
✓ Branch 0 taken 34170 times.
✓ Branch 1 taken 11390 times.
45560 for(int32_t j=0; j<3; j++)
5542 {
5543
2/4
✓ Branch 0 taken 34170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34170 times.
34170 if(!p_getc(&temp_misc.shop[i].item[j],f))
5544 {
5545 return qe_invalid;
5546 }
5547
5548
2/2
✓ Branch 0 taken 30570 times.
✓ Branch 1 taken 3600 times.
34170 if(s_version < 4)
5549 {
5550 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5551 3600 }
5552 34170 }
5553
5554
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 11006 times.
11390 if(Header->zelda_version < 0x193)
5555 {
5556
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&tempbyte,f))
5557 {
5558 return qe_invalid;
5559 }
5560 384 }
5561
5562
2/2
✓ Branch 0 taken 34170 times.
✓ Branch 1 taken 11390 times.
45560 for(int32_t j=0; j<3; j++)
5563 {
5564
2/4
✓ Branch 0 taken 34170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34170 times.
34170 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5565 {
5566 return qe_invalid;
5567 }
5568 34170 }
5569
5570
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 10190 times.
11390 if(s_version > 3)
5571 {
5572
2/2
✓ Branch 0 taken 30570 times.
✓ Branch 1 taken 10190 times.
40760 for(int32_t j=0; j<3; j++)
5573 {
5574
2/4
✓ Branch 0 taken 30570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30570 times.
✗ Branch 3 not taken.
30570 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5575 return qe_invalid;
5576 30570 }
5577 10190 }
5578
5579 /*
5580 if(s_version < 8)
5581 {
5582 for(int32_t j=0; j<3; j++)
5583 {
5584 (&temp_misc.shop[i].str[j])=0; //initialise.
5585 }
5586 }
5587 */
5588 11390 }
5589
5590 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5591
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxshops; ++i)
5592 {
5593
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 212992 times.
638976 for(int32_t j=0; j<3-1; j++)
5594 {
5595
2/2
✓ Branch 0 taken 638976 times.
✓ Branch 1 taken 425984 times.
1064960 for(int32_t k=0; k<2-j; k++)
5596 {
5597
2/2
✓ Branch 0 taken 24517 times.
✓ Branch 1 taken 614459 times.
638976 if(temp_misc.shop[i].hasitem[k]==0)
5598 {
5599 614459 swaptmp = temp_misc.shop[i].item[k];
5600 614459 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5601 614459 temp_misc.shop[i].item[k+1] = swaptmp;
5602 614459 swaptmp = temp_misc.shop[i].price[k];
5603 614459 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5604 614459 temp_misc.shop[i].price[k+1] = swaptmp;
5605 614459 swaptmp = temp_misc.shop[i].hasitem[k];
5606 614459 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5607 614459 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5608 614459 }
5609 638976 }
5610 425984 }
5611 212992 }
5612
5613 //infos
5614
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5615 {
5616
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&infos,f))
5617 {
5618 return qe_invalid;
5619 }
5620 808 }
5621
5622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (infos > NUM_INFOS)
5623 {
5624 return qe_invalid;
5625 }
5626
5627
5628
2/2
✓ Branch 0 taken 10696 times.
✓ Branch 1 taken 832 times.
11528 for(int32_t i=0; i<infos; i++)
5629 {
5630
2/2
✓ Branch 0 taken 9935 times.
✓ Branch 1 taken 761 times.
10696 if(s_version > 6)
5631 {
5632
2/4
✓ Branch 0 taken 9935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9935 times.
9935 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5633 {
5634 return qe_invalid;
5635 }
5636 9935 }
5637
5638
2/2
✓ Branch 0 taken 32088 times.
✓ Branch 1 taken 10696 times.
42784 for(int32_t j=0; j<3; j++)
5639 {
5640
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 864 times.
32376 if((Header->zelda_version < 0x192)||
5641
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30936 times.
31224 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5642 {
5643
3/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
1152 if(!p_getc(&tempbyte,f))
5644 {
5645 return qe_invalid;
5646 }
5647
5648 864 temp_misc.info[i].str[j]=tempbyte;
5649 864 }
5650 else
5651 {
5652
3/4
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 31224 times.
✗ Branch 3 not taken.
30936 if(!p_igetw(&temp_misc.info[i].str[j],f))
5653 {
5654 return qe_invalid;
5655 }
5656 }
5657 32088 }
5658
5659
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 10312 times.
10696 if(Header->zelda_version < 0x193)
5660 {
5661
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&tempbyte,f))
5662 {
5663 return qe_invalid;
5664 }
5665 384 }
5666
5667
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10600 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
10696 if((Header->zelda_version == 0x192)&&(Header->build>145))
5668 {
5669
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&padding,f))
5670 {
5671 return qe_invalid;
5672 }
5673 96 }
5674
5675
2/2
✓ Branch 0 taken 32088 times.
✓ Branch 1 taken 10696 times.
42784 for(int32_t j=0; j<3; j++)
5676 {
5677
2/4
✓ Branch 0 taken 32088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32088 times.
32088 if(!p_igetw(&temp_misc.info[i].price[j],f))
5678 {
5679 return qe_invalid;
5680 }
5681 32088 }
5682 10696 }
5683
5684 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5685
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxinfos; ++i)
5686 {
5687
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 212992 times.
638976 for(int32_t j=0; j<3-1; j++)
5688 {
5689
2/2
✓ Branch 0 taken 638976 times.
✓ Branch 1 taken 425984 times.
1064960 for(int32_t k=0; k<2-j; k++)
5690 {
5691
2/2
✓ Branch 0 taken 626864 times.
✓ Branch 1 taken 12112 times.
638976 if(temp_misc.info[i].str[k]==0)
5692 {
5693 626864 swaptmp = temp_misc.info[i].str[k];
5694 626864 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5695 626864 temp_misc.info[i].str[k+1] = swaptmp;
5696 626864 swaptmp = temp_misc.info[i].price[k];
5697 626864 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5698 626864 temp_misc.info[i].price[k+1] = swaptmp;
5699 626864 }
5700 638976 }
5701 425984 }
5702 212992 }
5703
5704
5705 //warp rings
5706
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 749 times.
832 if(s_version > 5)
5707 749 warprings++;
5708
5709
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5710 {
5711
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&warprings,f))
5712 {
5713 return qe_invalid;
5714 }
5715
5716
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 461 times.
808 if (warprings > NUM_WARP_RINGS)
5717 {
5718 // return qe_invalid;
5719 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5720 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5721 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5722 461 }
5723 808 }
5724
5725
2/2
✓ Branch 0 taken 8738 times.
✓ Branch 1 taken 832 times.
9570 for(int32_t i=0; i<warprings; i++)
5726 {
5727 // See above comment on the `warprings` range check.
5728 8738 bool keepdata = i < NUM_WARP_RINGS;
5729
5730
2/2
✓ Branch 0 taken 77522 times.
✓ Branch 1 taken 8738 times.
86260 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5731 {
5732
2/2
✓ Branch 0 taken 68562 times.
✓ Branch 1 taken 8960 times.
77522 if(s_version <= 3)
5733 {
5734
2/4
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8960 times.
✗ Branch 3 not taken.
8960 if(!p_getc(&tempbyte,f))
5735 {
5736 return qe_invalid;
5737 }
5738
5739
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5740 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5741 8960 }
5742 else
5743 {
5744 word tempword;
5745
2/4
✓ Branch 0 taken 68562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68562 times.
68562 if(!p_igetw(&tempword,f))
5746 {
5747 return qe_invalid;
5748 }
5749
5750
2/2
✓ Branch 0 taken 8199 times.
✓ Branch 1 taken 60363 times.
68562 if (keepdata)
5751 60363 temp_misc.warp[i].dmap[j] = tempword;
5752 }
5753 77522 }
5754
5755
2/2
✓ Branch 0 taken 8738 times.
✓ Branch 1 taken 77522 times.
86260 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5756 {
5757
2/4
✓ Branch 0 taken 77522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77522 times.
✗ Branch 3 not taken.
77522 if(!p_getc(&tempbyte,f))
5758 {
5759 return qe_invalid;
5760 }
5761
2/2
✓ Branch 0 taken 11391 times.
✓ Branch 1 taken 66131 times.
77522 if (keepdata)
5762 66131 temp_misc.warp[i].scr[j] = tempbyte;
5763 77522 }
5764
5765
2/4
✓ Branch 0 taken 8738 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8738 times.
✗ Branch 3 not taken.
8738 if(!p_getc(&tempbyte,f))
5766 {
5767 return qe_invalid;
5768 }
5769
2/2
✓ Branch 0 taken 1310 times.
✓ Branch 1 taken 7428 times.
8738 if (keepdata)
5770 7428 temp_misc.warp[i].size = tempbyte;
5771
5772
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 8546 times.
8738 if(Header->zelda_version < 0x193)
5773 {
5774
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5775 {
5776 return qe_invalid;
5777 }
5778 192 }
5779 8738 }
5780
5781 //palette cycles
5782
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5783 {
5784
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5785 {
5786
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5787 {
5788 18432 temp_misc.cycles[i][j].first=0;
5789 18432 temp_misc.cycles[i][j].count=0;
5790 18432 temp_misc.cycles[i][j].speed=0;
5791 18432 }
5792 6144 }
5793
5794
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5795
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5796 {
5797 18 palcycles=16;
5798 18 }
5799
5800
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1824 times.
1848 for(int32_t i=0; i<palcycles; i++)
5801 {
5802
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 5472 times.
7296 for(int32_t j=0; j<3; j++)
5803 {
5804
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5472 times.
✗ Branch 3 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5805 {
5806 return qe_invalid;
5807 }
5808
5809
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5472 times.
✗ Branch 3 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5810 {
5811 return qe_invalid;
5812 }
5813
5814
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5815 {
5816 return qe_invalid;
5817 }
5818 5472 }
5819 1824 }
5820 24 }
5821
5822 //Wind warps are now just another warp ring.
5823
2/2
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 83 times.
832 if(s_version <= 5)
5824 {
5825
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version > 0x192)
5826 {
5827
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&windwarps,f))
5828 {
5829 return qe_invalid;
5830 }
5831 59 }
5832
5833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5834 {
5835 return qe_invalid;
5836 }
5837
5838
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 665 times.
748 for(int32_t i=0; i<windwarps; i++)
5839 {
5840
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5841 {
5842
2/4
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 665 times.
✗ Branch 3 not taken.
665 if(!p_getc(&tempbyte,f))
5843 {
5844 return qe_invalid;
5845 }
5846
5847 665 temp_misc.warp[8].dmap[i]=tempbyte;
5848 665 }
5849 else
5850 {
5851 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5852 {
5853 return qe_invalid;
5854 }
5855 }
5856
5857
2/4
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 665 times.
✗ Branch 3 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5858 {
5859 return qe_invalid;
5860 }
5861
5862 665 temp_misc.warp[8].size = 9;
5863
5864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 665 times.
665 if(s_version == 5)
5865 {
5866 if(!p_getc(&tempbyte,f))
5867 {
5868 return qe_invalid;
5869 }
5870 }
5871 665 }
5872 83 }
5873
5874
5875 //triforce pieces
5876
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 6656 times.
7488 for(int32_t i=0; i<triforces; i++)
5877 {
5878
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6656 times.
6656 if(!p_getc(&temp_misc.triforce[i],f))
5879 {
5880 return qe_invalid;
5881 }
5882 6656 }
5883
5884 //misc color data
5885
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 749 times.
832 if(s_version<3)
5886 {
5887
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5888 {
5889 return qe_invalid;
5890 }
5891
5892
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5893 {
5894 return qe_invalid;
5895 }
5896
5897
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5898 {
5899 return qe_invalid;
5900 }
5901
5902
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5903 {
5904 return qe_invalid;
5905 }
5906
5907
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5908 {
5909 return qe_invalid;
5910 }
5911
5912
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5913 {
5914 return qe_invalid;
5915 }
5916
5917
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5918 {
5919 return qe_invalid;
5920 }
5921
5922
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5923 {
5924 return qe_invalid;
5925 }
5926
5927
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5928 {
5929 return qe_invalid;
5930 }
5931
5932
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5933 {
5934 return qe_invalid;
5935 }
5936
5937
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5938 {
5939 return qe_invalid;
5940 }
5941
5942
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5943 {
5944 return qe_invalid;
5945 }
5946
5947
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5948 {
5949 return qe_invalid;
5950 }
5951
5952
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5953 {
5954 return qe_invalid;
5955 }
5956
5957
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5958 {
5959 return qe_invalid;
5960 }
5961
5962
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5963 {
5964 return qe_invalid;
5965 }
5966
5967
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5968 {
5969 return qe_invalid;
5970 }
5971
5972
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5973 {
5974 return qe_invalid;
5975 }
5976
5977
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5978 {
5979 return qe_invalid;
5980 }
5981
5982
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5983 {
5984 return qe_invalid;
5985 }
5986
5987
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5988 {
5989 return qe_invalid;
5990 }
5991
5992
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5993 {
5994 return qe_invalid;
5995 }
5996
5997
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5998 {
5999 return qe_invalid;
6000 }
6001
6002
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6003 {
6004 return qe_invalid;
6005 }
6006
6007
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6008 {
6009 return qe_invalid;
6010 }
6011
6012
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6013 {
6014 return qe_invalid;
6015 }
6016
6017
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6018 {
6019 return qe_invalid;
6020 }
6021
6022 83 temp_misc.colors.msgtext = 0x01;
6023
6024
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6025 {
6026
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6027 {
6028
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 if(!p_getc(&tempbyte,f))
6029 {
6030 return qe_invalid;
6031 }
6032 168 }
6033 24 }
6034
6035
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6036 {
6037
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6038 {
6039
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&tempbyte,f))
6040 {
6041 return qe_invalid;
6042 }
6043 1536 }
6044 6 }
6045
6046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(s_version>1)
6047 {
6048 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6049 {
6050 return qe_invalid;
6051 }
6052 }
6053
6054 //save game icons
6055
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6056
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6057 {
6058 18 icons=3;
6059 18 }
6060
6061
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6062 {
6063
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6064 {
6065 return qe_invalid;
6066 }
6067 314 }
6068 83 }
6069
6070
3/4
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
838 if((Header->zelda_version < 0x192)||
6071
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 808 times.
814 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6072 {
6073
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 *Misc = temp_misc;
6074
6075 18 return 0;
6076 }
6077
6078 //pond information
6079
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 6 times.
814 if(Header->zelda_version < 0x193)
6080 {
6081
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6082 {
6083 pondsize=25;
6084 }
6085
6086
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6087 {
6088
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6089 {
6090
2/4
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6912 times.
✗ Branch 3 not taken.
6912 if(!p_getc(&tempbyte,f))
6091 {
6092 return qe_invalid;
6093
6094 }
6095 6912 }
6096 96 }
6097 6 }
6098
6099 //end string
6100 820 if((Header->zelda_version < 0x192)||
6101
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 808 times.
814 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6102 {
6103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!p_getc(&tempbyte,f))
6104 {
6105 return qe_invalid;
6106 }
6107
6108 temp_misc.endstring=tempbyte;
6109
6110 if(!p_getc(&tempbyte,f))
6111 {
6112 return qe_invalid;
6113 }
6114 }
6115 else
6116 {
6117
3/4
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 814 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&temp_misc.endstring,f))
6118 {
6119 return qe_invalid;
6120 }
6121 }
6122
6123 //expansion
6124
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 6 times.
814 if(Header->zelda_version < 0x193)
6125 {
6126
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6127 {
6128 expansionsize=99*2;
6129 }
6130
6131
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6132 {
6133
2/4
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1176 times.
✗ Branch 3 not taken.
1176 if(!p_getc(&tempbyte,f))
6134 {
6135 return qe_invalid;
6136 }
6137 1176 }
6138 6 }
6139 //shops v8
6140
6141
6142
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 215 times.
814 if(s_version >= 8)
6143 {
6144
2/2
✓ Branch 0 taken 2528 times.
✓ Branch 1 taken 215 times.
2743 for(int32_t i=0; i<shops; i++)
6145 {
6146
2/2
✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 2528 times.
10112 for(int32_t j=0; j<3; j++)
6147 {
6148
2/4
✓ Branch 0 taken 7584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7584 times.
✗ Branch 3 not taken.
7584 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6149 return qe_invalid;
6150 7584 }
6151 2528 }
6152 215 }
6153
6154 814 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6155 814 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6156
6157 //v9 includes quest misc[32]
6158 // ... this has been deprecated (2024)
6159
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 215 times.
814 if(s_version >= 9)
6160 {
6161
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 6880 times.
7095 for ( int32_t q = 0; q < 32; q++ )
6162 {
6163
2/4
✓ Branch 0 taken 6880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6880 times.
✗ Branch 3 not taken.
6880 if(!p_igetl(&temp_misc.questmisc[q],f))
6164 return qe_invalid;
6165 6880 }
6166 // this was string labels
6167
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if (pack_fseek(f, 32 * 128))
6168 return qe_invalid;
6169 215 }
6170
6171
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 11 )
6172 {
6173
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6174 return qe_invalid;
6175 215 }
6176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
599 else if(s_version < 11 )
6177 {
6178 599 temp_misc.zscript_last_compiled_version = -1;
6179 599 }
6180
6181 814 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6182
6183
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 12)
6184 {
6185 byte spr;
6186
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t q = 0; q < sprMAX; ++q)
6187 {
6188
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(!p_getc(&spr,f))
6189 return qe_invalid;
6190 55040 temp_misc.sprites[q] = spr;
6191 55040 }
6192 215 }
6193 else
6194 {
6195 599 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6196 //temp_misc.sprites[sprFALL] = ;
6197 }
6198
6199
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 13)
6200 {
6201
2/2
✓ Branch 0 taken 13760 times.
✓ Branch 1 taken 215 times.
13975 for(size_t q = 0; q < 64; ++q)
6202 {
6203 13760 bottletype* bt = &(temp_misc.bottle_types[q]);
6204
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6205 return qe_invalid;
6206
2/2
✓ Branch 0 taken 13760 times.
✓ Branch 1 taken 41280 times.
55040 for(size_t j = 0; j < 3; ++j)
6207 {
6208
2/4
✓ Branch 0 taken 41280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41280 times.
✗ Branch 3 not taken.
41280 if (!p_getc(&(bt->counter[j]), f))
6209 return qe_invalid;
6210
2/4
✓ Branch 0 taken 41280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41280 times.
✗ Branch 3 not taken.
41280 if (!p_igetw(&(bt->amount[j]), f))
6211 return qe_invalid;
6212 41280 }
6213
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getc(&(bt->flags), f))
6214 return qe_invalid;
6215
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getc(&(bt->next_type), f))
6216 return qe_invalid;
6217 13760 }
6218
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(size_t q = 0; q < 256; ++q)
6219 {
6220 55040 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6221
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6222 return qe_invalid;
6223
2/2
✓ Branch 0 taken 165120 times.
✓ Branch 1 taken 55040 times.
220160 for(size_t j = 0; j < 3; ++j)
6224 {
6225
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_getc(&(bst->fill[j]), f))
6226 return qe_invalid;
6227
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->comb[j]), f))
6228 return qe_invalid;
6229
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_getc(&(bst->cset[j]), f))
6230 return qe_invalid;
6231
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->price[j]), f))
6232 return qe_invalid;
6233
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->str[j]), f))
6234 return qe_invalid;
6235 165120 }
6236 55040 }
6237 215 }
6238 else
6239 {
6240
2/2
✓ Branch 0 taken 38336 times.
✓ Branch 1 taken 599 times.
38935 for(size_t q = 0; q < 64; ++q)
6241
1/2
✓ Branch 0 taken 38336 times.
✗ Branch 1 not taken.
38336 temp_misc.bottle_types[q].clear();
6242
2/2
✓ Branch 0 taken 153344 times.
✓ Branch 1 taken 599 times.
153943 for(size_t q = 0; q < 256; ++q)
6243
1/2
✓ Branch 0 taken 153344 times.
✗ Branch 1 not taken.
153344 temp_misc.bottle_shop_types[q].clear();
6244 }
6245
6246
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 14)
6247 {
6248 byte msfx;
6249
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t q = 0; q < sfxMAX; ++q)
6250 {
6251
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(!p_getc(&msfx,f))
6252 return qe_invalid;
6253 55040 temp_misc.miscsfx[q] = msfx;
6254 55040 }
6255 215 }
6256 else
6257 {
6258 599 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6259 599 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6260 599 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6261 }
6262
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version < 15)
6263 {
6264 599 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6265 599 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6266 599 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6267 599 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6268 599 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6269 599 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6270 599 }
6271
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 616 times.
814 if(s_version < 16)
6272 {
6273 616 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6274 616 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6275 616 }
6276
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 681 times.
814 if (s_version >= 17)
6277 {
6278 133 byte save_menu_count = 0;
6279
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&save_menu_count, f))
6280 return qe_invalid;
6281
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 for(size_t q = 0; q < save_menu_count; ++q)
6282 {
6283 SaveMenu& menu = temp_misc.save_menus[q];
6284 menu.clear();
6285
6286 byte menu_empty;
6287 if (!p_getc(&menu_empty, f))
6288 return qe_invalid;
6289 if (menu_empty)
6290 continue;
6291
6292 if (!p_getcstr(&menu.name, f))
6293 return qe_invalid;
6294
6295 if (!p_igetw(&menu.flags, f))
6296 return qe_invalid;
6297
6298 if (!p_igetl(&menu.cursor_tile, f))
6299 return qe_invalid;
6300
6301 if (!p_getc(&menu.cursor_cset, f))
6302 return qe_invalid;
6303
6304 if (!p_getc(&menu.cursor_sfx, f))
6305 return qe_invalid;
6306
6307 if (!p_getc(&menu.choose_sfx, f))
6308 return qe_invalid;
6309
6310 if (!p_getc(&menu.bg_color, f))
6311 return qe_invalid;
6312
6313 if (!p_getc(&menu.hspace, f))
6314 return qe_invalid;
6315
6316 if (!p_getc(&menu.vspace, f))
6317 return qe_invalid;
6318
6319 if (!p_getc(&menu.opt_x, f))
6320 return qe_invalid;
6321
6322 if (!p_getc(&menu.opt_y, f))
6323 return qe_invalid;
6324
6325 if (!p_getc(&menu.text_align, f))
6326 return qe_invalid;
6327
6328 if (!p_getc(&menu.textbox_align, f))
6329 return qe_invalid;
6330
6331 if (!p_igetw(&menu.close_frames, f))
6332 return qe_invalid;
6333
6334 if (!p_getc(&menu.close_flash_rate, f))
6335 return qe_invalid;
6336
6337 if (!p_igetw(&menu.midi, f))
6338 return qe_invalid;
6339
6340 if (!p_igetl(&menu.bg_tile, f))
6341 return qe_invalid;
6342
6343 if (!p_getc(&menu.bg_cset, f))
6344 return qe_invalid;
6345
6346 if (!p_getc(&menu.bg_tw, f))
6347 return qe_invalid;
6348
6349 if (!p_getc(&menu.bg_th, f))
6350 return qe_invalid;
6351
6352 byte opt_count;
6353 if (!p_getc(&opt_count, f))
6354 return qe_invalid;
6355 menu.options.resize(opt_count);
6356
6357 for (size_t q = 0; q < opt_count; ++q)
6358 {
6359 SaveMenuOption& opt = menu.options[q];
6360
6361 if (!p_getcstr(&opt.text, f))
6362 return qe_invalid;
6363
6364 if (!p_igetw(&opt.flags, f))
6365 return qe_invalid;
6366
6367 if (!p_getc(&opt.color, f))
6368 return qe_invalid;
6369
6370 if (!p_getc(&opt.picked_color, f))
6371 return qe_invalid;
6372
6373 if (!p_igetl(&opt.font, f))
6374 return qe_invalid;
6375
6376 if (!p_igetw(&opt.gen_script, f))
6377 return qe_invalid;
6378 }
6379 }
6380
6381
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&temp_misc.savemenu_game_over, f))
6382 return qe_invalid;
6383
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&temp_misc.savemenu_f6, f))
6384 return qe_invalid;
6385 133 }
6386
6387
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 1 times.
814 if (!should_skip)
6388
1/2
✓ Branch 0 taken 813 times.
✗ Branch 1 not taken.
813 *Misc = temp_misc;
6389
6390 814 return 0;
6391 2008 }
6392
6393 extern char *item_string[MAXITEMS];
6394 extern const char *old_item_string[iLast];
6395 extern char *weapon_string[MAXWPNS];
6396 extern const char *old_weapon_string[wLast];
6397
6398 498 int32_t readitems(PACKFILE *f, word version, word build)
6399 {
6400
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6401
6402 byte padding;
6403 int32_t dummy;
6404 498 word items_to_read=MAXITEMS;
6405 498 itemdata tempitem;
6406 498 word s_version=0;
6407 word dummy_word;
6408
6409
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(version < 0x186)
6410 {
6411 6 items_to_read=64;
6412 6 }
6413
6414
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(version > 0x192)
6415 {
6416 474 items_to_read=0;
6417
6418 //section version info
6419
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
6420 {
6421 return qe_invalid;
6422 }
6423
6424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_ITEMS)
6425 return qe_version;
6426
6427 474 FFCore.quest_format[vItems] = s_version;
6428
6429
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
6430 {
6431 return qe_invalid;
6432 }
6433
6434 //section size
6435
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
6436 {
6437 return qe_invalid;
6438 }
6439
6440 //finally... section data
6441
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&items_to_read,f))
6442 {
6443 return qe_invalid;
6444 }
6445
6446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (items_to_read > MAXITEMS)
6447 {
6448 return qe_invalid;
6449 }
6450 474 }
6451
6452
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 83 times.
498 if(s_version>1)
6453 {
6454
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i=0; i<items_to_read; i++)
6455 {
6456 char tempname[64];
6457
6458
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!pfread(tempname, 64, f))
6459 {
6460 return qe_invalid;
6461 }
6462
6463 106240 item_string[i][0] = '\0';
6464 106240 strncat(item_string[i], tempname, 64 - 1);
6465 106240 }
6466 415 }
6467
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6468 {
6469
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6470 {
6471 20992 reset_itemname(i);
6472 20992 }
6473 82 }
6474
6475
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
6476
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMS; i++)
6477 {
6478 127232 itemdata& id = itemsbuf[i];
6479 127232 memset(&id, 0, sizeof(itemdata));
6480 127232 id.count=-1;
6481 127232 id.playsound=WAV_SCALE;
6482 127232 reset_itembuf(&id,i);
6483 127729 }
6484
6485
2/2
✓ Branch 0 taken 115362 times.
✓ Branch 1 taken 498 times.
115860 for(int32_t i=0; i<items_to_read; i++)
6486 {
6487 115362 tempitem = itemdata();
6488 115362 reset_itembuf(&tempitem,i);
6489
6490
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 60322 times.
115362 if ( s_version > 35 ) //expanded tiles
6491 {
6492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tile,f))
6493 {
6494 return qe_invalid;
6495 }
6496 55040 }
6497 else
6498 {
6499
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6500 {
6501 return qe_invalid;
6502 }
6503 }
6504
6505
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.misc_flags,f))
6506 {
6507 return qe_invalid;
6508 }
6509
6510
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.csets,f))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.frames,f))
6516 {
6517 return qe_invalid;
6518 }
6519
6520
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.speed,f))
6521 {
6522 return qe_invalid;
6523 }
6524
6525
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.delay,f))
6526 {
6527 return qe_invalid;
6528 }
6529
6530
2/2
✓ Branch 0 taken 110370 times.
✓ Branch 1 taken 4992 times.
115362 if(version < 0x193)
6531 {
6532
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6533 {
6534 return qe_invalid;
6535 }
6536
6537
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6538 {
6539
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6540 256 continue;
6541
6542
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6543 {
6544 case iShield:
6545 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6546 23 break;
6547
6548 case iMShield:
6549 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6550 23 break;
6551
6552 default:
6553 4690 tempitem.ltm=0;
6554 4690 break;
6555 }
6556
6557 4736 tempitem.count=-1;
6558 4736 tempitem.flags=item_none;
6559 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6560 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6561 4736 tempitem.type=0xFF;
6562 4736 tempitem.playsound=WAV_SCALE;
6563 4736 reset_itembuf(&tempitem,i);
6564
6565 4736 itemsbuf[i] = tempitem;
6566
6567 4736 continue;
6568 }
6569 }
6570
6571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110370 times.
110370 if(!p_igetl(&tempitem.ltm,f))
6572 {
6573 return qe_invalid;
6574 }
6575
6576
1/2
✓ Branch 0 taken 110370 times.
✗ Branch 1 not taken.
110370 if(version < 0x193)
6577 {
6578 for(int32_t q=0; q<12; q++)
6579 {
6580 if(!p_getc(&padding,f))
6581 {
6582 return qe_invalid;
6583 }
6584 }
6585 }
6586
6587
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 4130 times.
110370 if(s_version>1)
6588 {
6589
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if ( s_version >= 31 )
6590 {
6591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.type,f))
6592 {
6593 return qe_invalid;
6594 }
6595 55040 }
6596 else
6597 {
6598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6599 {
6600 return qe_invalid;
6601 }
6602 }
6603
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version < 16)
6604 if(tempitem.type == 0xFF)
6605 tempitem.type = itype_misc;
6606
6607
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.level,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version>5)
6613 {
6614
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if(s_version>=31)
6615 {
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.power,f))
6617 {
6618 return qe_invalid;
6619 }
6620 55040 }
6621 else
6622 {
6623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6624 {
6625 return qe_invalid;
6626 }
6627 }
6628
6629 //converted flags from 16b to 32b -Z
6630
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version < 41 )
6631 {
6632
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6633 {
6634 return qe_invalid;
6635 }
6636 51200 }
6637 else
6638 {
6639
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.flags,f))
6640 {
6641 return qe_invalid;
6642 }
6643 }
6644 106240 }
6645 else
6646 {
6647 //tempitem.power = tempitem.fam_type;
6648 char tempchar;
6649
6650 if(!p_getc(&tempchar,f))
6651 {
6652 return qe_invalid;
6653 }
6654
6655 if (tempchar) tempitem.flags |= item_gamedata;
6656 }
6657
6658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.script,f))
6659 {
6660 return qe_invalid;
6661 }
6662
6663
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<=3)
6664 {
6665 if(tempitem.script > NUMSCRIPTITEM)
6666 {
6667 tempitem.script = 0;
6668 }
6669 }
6670
6671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.count,f))
6672 {
6673 return qe_invalid;
6674 }
6675
6676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.amount,f))
6677 {
6678 return qe_invalid;
6679 }
6680
6681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.collect_script,f))
6682 {
6683 return qe_invalid;
6684 }
6685
6686
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<=3)
6687 {
6688 if(tempitem.collect_script > NUMSCRIPTITEM)
6689 {
6690 tempitem.collect_script = 0;
6691 }
6692 }
6693
6694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.setmax,f))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetw(&tempitem.max,f))
6700 {
6701 return qe_invalid;
6702 }
6703
6704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.playsound,f))
6705 {
6706 return qe_invalid;
6707 }
6708
6709
2/2
✓ Branch 0 taken 849920 times.
✓ Branch 1 taken 106240 times.
956160 for(int32_t j=0; j<8; j++)
6710 {
6711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 849920 times.
849920 if(!p_igetl(&tempitem.initiald[j],f))
6712 {
6713 return qe_invalid;
6714 }
6715 849920 }
6716
6717
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 106240 times.
318720 for(int32_t j=0; j<2; j++)
6718 {
6719 byte temp;
6720
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&temp,f))
6721 {
6722 return qe_invalid;
6723 }
6724 212480 }
6725
6726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>4)
6727 {
6728
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version>5)
6729 {
6730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn,f))
6731 {
6732 return qe_invalid;
6733 }
6734
6735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn2,f))
6736 {
6737 return qe_invalid;
6738 }
6739
6740
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn3,f))
6741 {
6742 return qe_invalid;
6743 }
6744
6745
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn4,f))
6746 {
6747 return qe_invalid;
6748 }
6749
6750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>=15)
6751 {
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn5,f))
6753 {
6754 return qe_invalid;
6755 }
6756
6757
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn6,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn7,f))
6763 {
6764 return qe_invalid;
6765 }
6766
6767
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn8,f))
6768 {
6769 return qe_invalid;
6770 }
6771
6772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn9,f))
6773 {
6774 return qe_invalid;
6775 }
6776
6777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn10,f))
6778 {
6779 return qe_invalid;
6780 }
6781 106240 }
6782
6783
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.pickup_hearts,f))
6784 {
6785 return qe_invalid;
6786 }
6787
6788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version<15)
6789 {
6790 if(!p_igetw(&dummy_word,f))
6791 {
6792 return qe_invalid;
6793 }
6794
6795 tempitem.misc1=dummy_word;
6796
6797 if(!p_igetw(&dummy_word,f))
6798 {
6799 return qe_invalid;
6800 }
6801
6802 tempitem.misc2=dummy_word;
6803 }
6804 else
6805 {
6806
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc1,f))
6807 {
6808 return qe_invalid;
6809 }
6810
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc2,f))
6812 {
6813 return qe_invalid;
6814 }
6815
6816 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6817
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<24)
6818 {
6819 if(tempitem.type==itype_shield)
6820 {
6821 tempitem.misc1|=sh_script;
6822 }
6823 }
6824 }
6825
6826
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if(s_version < 53)
6827 {
6828 byte tempbyte;
6829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6830 {
6831 return qe_invalid;
6832 }
6833 51200 tempitem.cost_amount[0] = tempbyte;
6834 51200 }
6835 else
6836 {
6837
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < 2; ++q)
6838 {
6839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_igetw(&tempitem.cost_amount[q],f))
6840 {
6841 return qe_invalid;
6842 }
6843 110080 }
6844 }
6845 106240 }
6846 else
6847 {
6848 char tempchar;
6849
6850 if(!p_getc(&tempchar,f))
6851 {
6852 return qe_invalid;
6853 }
6854
6855 if (tempchar) tempitem.flags |= item_edible;
6856 }
6857
6858 // June 2007: more misc. attributes
6859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>=12)
6860 {
6861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version<15)
6862 {
6863 if(!p_igetw(&dummy_word,f))
6864 {
6865 return qe_invalid;
6866 }
6867
6868 tempitem.misc3=dummy_word;
6869
6870 if(!p_igetw(&dummy_word,f))
6871 {
6872 return qe_invalid;
6873 }
6874
6875 tempitem.misc4=dummy_word;
6876 }
6877 else
6878 {
6879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc3,f))
6880 {
6881 return qe_invalid;
6882 }
6883
6884
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc4,f))
6885 {
6886 return qe_invalid;
6887 }
6888
6889
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc5,f))
6890 {
6891 return qe_invalid;
6892 }
6893
6894
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc6,f))
6895 {
6896 return qe_invalid;
6897 }
6898
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc7,f))
6900 {
6901 return qe_invalid;
6902 }
6903
6904
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc8,f))
6905 {
6906 return qe_invalid;
6907 }
6908
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc9,f))
6910 {
6911 return qe_invalid;
6912 }
6913
6914
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc10,f))
6915 {
6916 return qe_invalid;
6917 }
6918 }
6919
6920
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.usesound,f))
6921 {
6922 return qe_invalid;
6923 }
6924
6925
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if(s_version >= 49)
6926 {
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_getc(&tempitem.usesound2,f))
6928 {
6929 return qe_invalid;
6930 }
6931 55040 }
6932 51200 else tempitem.usesound2 = 0;
6933
6934
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
106240 if(s_version < 50 && tempitem.type == itype_mirror)
6935 {
6936 //Split continue/dmap warp effect/sfx, port for old
6937 tempitem.misc2 = tempitem.misc1;
6938 tempitem.usesound2 = tempitem.usesound;
6939 }
6940 106240 }
6941 106240 }
6942
6943
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6944 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6945
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
6946 {
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13312 times.
13312 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_getc(&tempitem.weap_data.default_defense,f))
6952 {
6953 return qe_invalid;
6954 }
6955 13312 }
6956
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.weaprange,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.weapduration,f))
6961 {
6962 return qe_invalid;
6963 }
6964
2/2
✓ Branch 0 taken 550400 times.
✓ Branch 1 taken 55040 times.
605440 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6965 {
6966
1/2
✓ Branch 0 taken 550400 times.
✗ Branch 1 not taken.
550400 if(!p_igetl(&tempitem.weap_pattern[q],f))
6967 {
6968 return qe_invalid;
6969 }
6970 550400 }
6971 55040 }
6972
6973
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6974 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.duplicates,f))
6976 {
6977 return qe_invalid;
6978 }
6979
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
6980
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 13312 times.
119808 for ( int32_t q = 0; q < INITIAL_D; q++ )
6981
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6982 13312 return qe_invalid;
6983
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for ( int32_t q = 0; q < 2; q++ )
6984 {
6985 byte temp;
6986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_getc(&temp,f))
6987 {
6988 return qe_invalid;
6989 }
6990 110080 }
6991
6992
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempitem.drawlayer,f))
6993 {
6994 return qe_invalid;
6995 }
6996
6997
6998
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hxofs,f))
6999 {
7000 return qe_invalid;
7001 }
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.hyofs,f))
7003 {
7004 return qe_invalid;
7005 }
7006
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hxsz,f))
7007 {
7008 return qe_invalid;
7009 }
7010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.hysz,f))
7011 {
7012 return qe_invalid;
7013 }
7014
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hzsz,f))
7015 {
7016 return qe_invalid;
7017 }
7018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.xofs,f))
7019 {
7020 return qe_invalid;
7021 }
7022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.yofs,f))
7023 {
7024 return qe_invalid;
7025 }
7026
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
7027 {
7028
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hxofs,f))
7029 return qe_invalid;
7030
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hyofs,f))
7031 return qe_invalid;
7032
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hxsz,f))
7033 return qe_invalid;
7034
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hysz,f))
7035 return qe_invalid;
7036
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hzsz,f))
7037 return qe_invalid;
7038
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.xofs,f))
7039 return qe_invalid;
7040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13312 times.
13312 if(!p_igetl(&tempitem.weap_data.yofs,f))
7041 return qe_invalid;
7042 13312 }
7043
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
7044
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetw(&tempitem.weap_data.script,f))
7045 return qe_invalid;
7046
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.wpnsprite,f))
7047 {
7048 return qe_invalid;
7049 }
7050 55040 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7051
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < num_cost_tmr; ++q)
7052 {
7053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7054 {
7055 return qe_invalid;
7056 }
7057 110080 }
7058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 for(auto q = num_cost_tmr; q < 2; ++q)
7059 tempitem.magiccosttimer[q] = 0;
7060 55040 }
7061
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7062 {
7063 //Item Size FLags, TileWidth, TileHeight
7064
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.overrideFLAGS,f))
7065 {
7066 return qe_invalid;
7067 }
7068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tilew,f))
7069 {
7070 return qe_invalid;
7071 }
7072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tileh,f))
7073 {
7074 return qe_invalid;
7075 }
7076 55040 }
7077
4/4
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 41728 times.
✓ Branch 3 taken 13312 times.
106240 if ( s_version >= 29 && s_version < 63) //! More new vars.
7078 {
7079
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.override_flags,f))
7080 return qe_invalid;
7081
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.tilew,f))
7082 return qe_invalid;
7083
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.tileh,f))
7084 return qe_invalid;
7085 13312 }
7086
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 30 ) //! More new vars.
7087 {
7088 //Pickup Type
7089
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.pickup,f))
7090 {
7091 return qe_invalid;
7092 }
7093 55040 }
7094
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 32 ) //! More new vars.
7095 {
7096 //Pickup Type
7097
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.pstring,f))
7098 {
7099 return qe_invalid;
7100 }
7101 55040 }
7102
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 33 ) //! More new vars.
7103 {
7104 //Pickup Type
7105
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.pickup_string_flags,f))
7106 {
7107 return qe_invalid;
7108 }
7109 55040 }
7110
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 34 ) //! cost counter
7111 {
7112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(s_version < 53)
7113 {
7114 if(!p_getc(&tempitem.cost_counter[0],f))
7115 {
7116 return qe_invalid;
7117 }
7118 }
7119 else
7120 {
7121
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < 2; ++q)
7122 {
7123
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&tempitem.cost_counter[q],f))
7124 {
7125 return qe_invalid;
7126 }
7127 110080 }
7128 }
7129 55040 }
7130
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 44 ) //! sprite scripts
7131 {
7132
2/2
✓ Branch 0 taken 440320 times.
✓ Branch 1 taken 55040 times.
495360 for ( int32_t q = 0; q < 8; q++ )
7133 {
7134
2/2
✓ Branch 0 taken 28620800 times.
✓ Branch 1 taken 440320 times.
29061120 for ( int32_t w = 0; w < 65; w++ )
7135 {
7136
1/2
✓ Branch 0 taken 28620800 times.
✗ Branch 1 not taken.
28620800 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7137 {
7138 return qe_invalid;
7139 }
7140 28620800 }
7141
2/2
✓ Branch 0 taken 333824 times.
✓ Branch 1 taken 106496 times.
440320 if(s_version < 63)
7142
2/2
✓ Branch 0 taken 6922240 times.
✓ Branch 1 taken 106496 times.
7028736 for ( int32_t w = 0; w < 65; w++ )
7143
1/2
✓ Branch 0 taken 6922240 times.
✗ Branch 1 not taken.
6922240 if(!p_getc(&padding,f))
7144 106496 return qe_invalid;
7145
2/2
✓ Branch 0 taken 28620800 times.
✓ Branch 1 taken 440320 times.
29061120 for ( int32_t w = 0; w < 65; w++ )
7146 {
7147
1/2
✓ Branch 0 taken 28620800 times.
✗ Branch 1 not taken.
28620800 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7148 {
7149 return qe_invalid;
7150 }
7151 28620800 }
7152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 440320 times.
440320 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7153 {
7154 return qe_invalid;
7155 }
7156
7157 440320 }
7158
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for ( int32_t q = 0; q < 2; q++ )
7159 {
7160 byte temp;
7161
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&temp,f))
7162 {
7163 return qe_invalid;
7164 }
7165 110080 }
7166 //Pickup Type
7167
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.sprite_script,f))
7168 {
7169 return qe_invalid;
7170 }
7171 55040 }
7172
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 48 ) //! pickup flags
7173 {
7174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_getc(&(tempitem.pickupflag),f))
7175 {
7176 return qe_invalid;
7177 }
7178 55040 }
7179
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 51712 times.
106240 if ( s_version >= 57 )
7180 {
7181 51712 std::string str;
7182
2/4
✓ Branch 0 taken 51712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51712 times.
✗ Branch 3 not taken.
51712 if(!p_getcstr(&str,f))
7183 return qe_invalid;
7184 51712 strncpy(tempitem.display_name,str.c_str(),255);
7185
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 51712 times.
51712 }
7186 106240 }
7187 else
7188 {
7189 4130 tempitem.count=-1;
7190 4130 tempitem.type=itype_misc;
7191 4130 tempitem.flags=item_none;
7192 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7193 4130 tempitem.playsound=WAV_SCALE;
7194 4130 reset_itembuf(&tempitem,i);
7195 }
7196
7197
4/4
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 41728 times.
✓ Branch 3 taken 8960 times.
110370 if(s_version >= 58 && s_version < 63)
7198 {
7199
2/2
✓ Branch 0 taken 44800 times.
✓ Branch 1 taken 8960 times.
53760 for(int q = 0; q < WPNSPR_MAX; ++q)
7200 {
7201
1/2
✓ Branch 0 taken 44800 times.
✗ Branch 1 not taken.
44800 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7202 return qe_invalid;
7203
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 43520 times.
44800 if(s_version >= 59)
7204
1/2
✓ Branch 0 taken 43520 times.
✗ Branch 1 not taken.
43520 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7205 return qe_invalid;
7206 44800 }
7207 8960 }
7208
7209
2/2
✓ Branch 0 taken 67106 times.
✓ Branch 1 taken 43264 times.
110370 if ( s_version >= 60 )
7210 {
7211
2/2
✓ Branch 0 taken 39168 times.
✓ Branch 1 taken 4096 times.
43264 if ( s_version >= 65 )
7212 {
7213
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempitem.pickup_litems,f))
7214 return qe_invalid;
7215 39168 }
7216 else
7217 {
7218
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_getc(&padding,f))
7219 return qe_invalid;
7220 4096 tempitem.pickup_litems = word(padding);
7221 }
7222
1/2
✓ Branch 0 taken 43264 times.
✗ Branch 1 not taken.
43264 if(!p_igetw(&tempitem.pickup_litem_level,f))
7223 return qe_invalid;
7224 43264 }
7225
7226
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 67106 times.
110370 if ( s_version >= 62 )
7227 {
7228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43264 times.
43264 if (!p_igetl(&tempitem.moveflags, f))
7229 return qe_invalid;
7230
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 1536 times.
43264 if(s_version < 63)
7231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7232 return qe_invalid;
7233 43264 }
7234 else
7235 {
7236 67106 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7237
3/3
✓ Branch 0 taken 1932 times.
✓ Branch 1 taken 64872 times.
✓ Branch 2 taken 302 times.
67106 switch(tempitem.type)
7238 {
7239 case itype_divinefire:
7240
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 135 times.
302 if(!(tempitem.flags & item_flag3))
7241 135 break;
7242 [[fallthrough]];
7243 case itype_bomb: case itype_sbomb:
7244 case itype_bait: case itype_liftglove:
7245 case itype_candle: case itype_book:
7246 2099 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7247 2099 break;
7248 default:
7249 64872 tempitem.weap_data.moveflags = move_none;
7250 64872 break;
7251 }
7252 }
7253
7254
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 68642 times.
110370 if(s_version >= 63)
7255 {
7256
1/2
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
41728 if(auto ret = read_weap_data(tempitem.weap_data, f))
7257 return ret;
7258 41728 }
7259 else
7260 {
7261
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 68624 times.
68642 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7262
3/3
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 67944 times.
✓ Branch 2 taken 66 times.
68642 switch(tempitem.type)
7263 {
7264 case itype_liftglove:
7265 66 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7266 66 break;
7267 case itype_bomb: case itype_sbomb:
7268 // Moving these over and removing them from itemdata
7269
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 24 times.
632 if(tempitem.flags & item_flag3)
7270 24 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7271
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 24 times.
632 if(tempitem.flags & item_flag5)
7272 24 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7273 632 tempitem.flags &= ~(item_flag3|item_flag5);
7274
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 18 times.
632 if(tempitem.misc4)
7275 {
7276 18 tempitem.weap_data.lift_level = tempitem.misc4;
7277 18 tempitem.weap_data.lift_time = tempitem.misc5;
7278 18 tempitem.weap_data.lift_height = tempitem.misc6;
7279 18 tempitem.misc4 = 0;
7280 18 tempitem.misc5 = 0;
7281 18 tempitem.misc6 = 0;
7282 18 }
7283 632 break;
7284 }
7285 }
7286
7287
2/2
✓ Branch 0 taken 71202 times.
✓ Branch 1 taken 39168 times.
110370 if (s_version >= 64)
7288 {
7289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39168 times.
39168 if (!p_igetl(&tempitem.cooldown, f))
7290 return qe_invalid;
7291 39168 }
7292
7293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110370 times.
110370 if (!should_skip)
7294 {
7295
1/2
✓ Branch 0 taken 110370 times.
✗ Branch 1 not taken.
110370 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7296 {
7297 tempitem.script = 0;
7298 tempitem.weap_data.script = 0;
7299 for(int q = 0; q < 8; ++q)
7300 {
7301 tempitem.initiald[q] = 0;
7302 tempitem.weap_data.initd[q] = 0;
7303 }
7304 }
7305 110370 itemsbuf[i] = tempitem;
7306 110370 }
7307 110370 }
7308
7309
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (should_skip)
7310 1 return 0;
7311
7312 //////////////////////////////////////////////////////
7313 // Now do any updates because of new item additions
7314 // (These can't be done above because items_to_read
7315 // might be too low.)
7316 //////////////////////////////////////////////////////
7317
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMS; i++)
7318 {
7319 127232 tempitem = itemsbuf[i];
7320
7321 //Account for older quests that didn't have an actual item for the used letter
7322
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 2 && i==iLetterUsed)
7323 {
7324 82 reset_itembuf(&tempitem, iLetterUsed);
7325 82 strcpy(item_string[i],old_item_string[i]);
7326 82 tempitem.tile = itemsbuf[iLetter].tile;
7327 82 tempitem.csets = itemsbuf[iLetter].csets;
7328 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7329 82 tempitem.frames = itemsbuf[iLetter].frames;
7330 82 tempitem.speed = itemsbuf[iLetter].speed;
7331 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7332 82 }
7333
7334
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 3)
7335 {
7336
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7337 {
7338 case iRocsFeather:
7339 case iHoverBoots:
7340 case iSpinScroll:
7341 case iL2SpinScroll:
7342 case iCrossScroll:
7343 case iQuakeScroll:
7344 case iL2QuakeScroll:
7345 case iWhispRing:
7346 case iL2WhispRing:
7347 case iChargeRing:
7348 case iL2ChargeRing:
7349 case iPerilScroll:
7350 case iWalletL3:
7351 case iQuiverL4:
7352 case iBombBagL4:
7353 case iBracelet:
7354 case iL2Bracelet:
7355 case iOldGlove:
7356 case iL2Ladder:
7357 case iWealthMedal:
7358 case iL2WealthMedal:
7359 case iL3WealthMedal:
7360 1804 reset_itembuf(&tempitem, i);
7361 1804 strcpy(item_string[i],old_item_string[i]);
7362 1804 break;
7363
7364 case iSShield:
7365 82 reset_itembuf(&tempitem, i);
7366 82 strcpy(item_string[i],old_item_string[i]);
7367 82 strcpy(item_string[iShield],old_item_string[iShield]);
7368 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7369 82 break;
7370 }
7371 20992 }
7372
7373
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 5)
7374 {
7375
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7376 {
7377 case iHeartRing:
7378 case iL2HeartRing:
7379 case iL3HeartRing:
7380 case iMagicRing:
7381 case iL2MagicRing:
7382 case iL3MagicRing:
7383 case iL4MagicRing:
7384 574 reset_itembuf(&tempitem, i);
7385 574 strcpy(item_string[i],old_item_string[i]);
7386 574 break;
7387 }
7388 20992 }
7389
7390
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7391 {
7392
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7393
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7394
7395
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7396 {
7397 case iTriforce:
7398 82 tempitem.level=1;
7399 82 break;
7400
7401 case iBigTri:
7402 82 tempitem.level=0;
7403 82 break;
7404
7405 case iBombs:
7406 82 tempitem.level=i_bomb;
7407 82 tempitem.power=4;
7408 82 tempitem.wpn=wBOMB;
7409 82 tempitem.wpn2=wBOOM;
7410 82 tempitem.misc1 = 50;
7411
7412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7413
7414 82 break;
7415
7416 case iSBomb:
7417 82 tempitem.level=i_sbomb;
7418 82 tempitem.power=16;
7419 82 tempitem.wpn=wSBOMB;
7420 82 tempitem.wpn2=wSBOOM;
7421 82 tempitem.misc1 = 50;
7422
7423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7424
7425 82 break;
7426
7427 case iBook:
7428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7429 tempitem.wpn = wFIREMAGIC;
7430
7431 82 break;
7432
7433 case iSArrow:
7434 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7435 82 tempitem.power=4;
7436 82 tempitem.flags|=item_gamedata;
7437 82 tempitem.wpn=wSARROW;
7438 82 break;
7439
7440 case iGArrow:
7441 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7442 82 tempitem.power=8;
7443 82 tempitem.flags|=(item_gamedata|item_flag1);
7444 82 tempitem.wpn=wGARROW;
7445 82 break;
7446
7447 case iBrang:
7448 82 tempitem.power=0;
7449 82 tempitem.wpn=wBRANG;
7450 82 tempitem.misc1=36;
7451 82 break;
7452
7453 case iMBrang:
7454 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7455 82 tempitem.power=0;
7456 82 tempitem.wpn=wMBRANG;
7457 82 break;
7458
7459 case iFBrang:
7460 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7461 82 tempitem.power=2;
7462 82 tempitem.wpn=wFBRANG;
7463 82 break;
7464
7465 case iBoots:
7466 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7467 82 tempitem.power=7;
7468 82 break;
7469
7470 case iWand:
7471 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7472 82 tempitem.power=2;
7473 82 tempitem.wpn=wWAND;
7474 82 tempitem.wpn3=wMAGIC;
7475 82 break;
7476
7477 case iBCandle:
7478 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7479 82 tempitem.power=1;
7480 82 tempitem.flags|=(item_gamedata|item_flag1);
7481 82 tempitem.wpn3=wFIRE;
7482 82 break;
7483
7484 case iRCandle:
7485 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7486 82 tempitem.power=1;
7487 82 tempitem.wpn3=wFIRE;
7488 82 break;
7489
7490 case iSword:
7491 82 tempitem.power=1;
7492 82 tempitem.flags|= item_flag4 |item_flag2;
7493 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7494 82 tempitem.wpn2=wSWORDSLASH;
7495 82 break;
7496
7497 case iWSword:
7498 82 tempitem.power=2;
7499 82 tempitem.flags|= item_flag4 |item_flag2;
7500 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7501 82 tempitem.wpn2=wWSWORDSLASH;
7502 82 break;
7503
7504 case iMSword:
7505 82 tempitem.power=4;
7506 82 tempitem.flags|= item_flag4 |item_flag2;
7507 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7508 82 tempitem.wpn2=wMSWORDSLASH;
7509 82 break;
7510
7511 case iXSword:
7512 82 tempitem.power=8;
7513 82 tempitem.flags|= item_flag4 |item_flag2;
7514 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7515 82 tempitem.wpn2=wXSWORDSLASH;
7516 82 break;
7517
7518 case iDivineProtection:
7519 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7520 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7521 82 tempitem.wpn=wDIVINEPROTECTION1A;
7522 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7523 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7524 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7525 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7526 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7527 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7528 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7529 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7530 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7531 82 tempitem.misc1=512;
7532 82 tempitem.cost_amount[0]=64;
7533 82 break;
7534
7535 case iLens:
7536 82 tempitem.misc1=60;
7537 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7538 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7539 82 break;
7540
7541 case iArrow:
7542 82 tempitem.power=2;
7543 82 tempitem.wpn=wARROW;
7544 82 break;
7545
7546 case iHoverBoots:
7547 82 tempitem.misc1=45;
7548 82 tempitem.wpn=iwHover;
7549 82 break;
7550
7551 case iDivineFire:
7552 82 tempitem.power=8;
7553 82 tempitem.wpn=wDIVINEFIRE1A;
7554 82 tempitem.wpn2=wDIVINEFIRE1B;
7555 82 tempitem.wpn3=wDIVINEFIRES1A;
7556 82 tempitem.wpn4=wDIVINEFIRES1B;
7557 82 tempitem.misc1 = 32;
7558 82 tempitem.misc2 = 200;
7559 82 tempitem.cost_amount[0]=32;
7560 82 break;
7561
7562 case iDivineEscape:
7563 82 tempitem.cost_amount[0]=32;
7564 82 break;
7565
7566 case iHookshot:
7567 82 tempitem.power=0;
7568 82 tempitem.flags&=~item_flag1;
7569 82 tempitem.wpn=wHSHEAD;
7570 82 tempitem.wpn2=wHSCHAIN_H;
7571 82 tempitem.wpn4=wHSHANDLE;
7572 82 tempitem.wpn3=wHSCHAIN_V;
7573 82 tempitem.misc1=50;
7574 82 tempitem.misc2=100;
7575 82 break;
7576
7577 case iLongshot:
7578 82 tempitem.power=0;
7579 82 tempitem.flags&=~item_flag1;
7580 82 tempitem.wpn=wLSHEAD;
7581 82 tempitem.wpn2=wLSCHAIN_H;
7582 82 tempitem.wpn4=wLSHANDLE;
7583 82 tempitem.wpn3=wLSCHAIN_V;
7584 82 tempitem.misc1=99;
7585 82 tempitem.misc2=100;
7586 82 break;
7587
7588 case iHammer:
7589 82 tempitem.power=4;
7590 82 tempitem.wpn=wHAMMER;
7591 82 tempitem.wpn2=iwHammerSmack;
7592 82 break;
7593
7594 case iCByrna:
7595 82 tempitem.power=1;
7596 82 tempitem.wpn=wCBYRNA;
7597 82 tempitem.wpn2=wCBYRNASLASH;
7598 82 tempitem.wpn3=wCBYRNAORB;
7599 82 tempitem.misc1=4;
7600 82 tempitem.misc2=16;
7601 82 tempitem.misc3=1;
7602 82 tempitem.cost_amount[0]=1;
7603 82 break;
7604
7605 case iWhistle:
7606 82 tempitem.wpn=wWIND;
7607 82 tempitem.misc1=3;
7608 82 tempitem.flags|=item_flag1;
7609 82 break;
7610
7611 case iBRing:
7612 82 tempitem.power=2;
7613 82 tempitem.misc1=spBLUE;
7614 82 break;
7615
7616 case iRRing:
7617 82 tempitem.power=4;
7618 82 tempitem.misc1=spRED;
7619 82 break;
7620
7621 case iGRing:
7622 82 tempitem.power=8;
7623 82 tempitem.misc1=spGOLD;
7624 82 break;
7625
7626 case iSpinScroll:
7627 82 tempitem.power = 2;
7628 82 tempitem.misc1 = 1;
7629 82 break;
7630
7631 case iL2SpinScroll:
7632 82 tempitem.type=itype_spinscroll2;
7633 82 tempitem.level=1;
7634 82 tempitem.cost_amount[0]=8;
7635 82 tempitem.power=2;
7636 82 tempitem.misc1 = 20;
7637 82 break;
7638
7639 case iQuakeScroll:
7640 82 tempitem.misc1=0x10;
7641 82 tempitem.misc2=64;
7642 82 break;
7643
7644 case iL2QuakeScroll:
7645 82 tempitem.type=itype_quakescroll2;
7646 82 tempitem.level=1;
7647 82 tempitem.power = 2;
7648 82 tempitem.misc1=0x20;
7649 82 tempitem.misc2=192;
7650 82 tempitem.cost_amount[0]=8;
7651 82 break;
7652
7653 case iChargeRing:
7654 82 tempitem.misc1=64;
7655 82 tempitem.misc2=128;
7656 82 break;
7657
7658 case iL2ChargeRing:
7659 82 tempitem.misc1=32;
7660 82 tempitem.misc2=64;
7661 82 break;
7662
7663 case iOldGlove:
7664 82 tempitem.flags |= item_flag1;
7665
7666 //fallthrough
7667 case iBombBagL4:
7668 case iWalletL3:
7669 case iQuiverL4:
7670 case iBracelet:
7671 410 tempitem.power = 1;
7672 410 break;
7673
7674 case iL2Bracelet:
7675 82 tempitem.power = 2;
7676 82 break;
7677
7678 case iMKey:
7679 82 tempitem.power=0xFF;
7680 82 tempitem.flags |= item_flag1;
7681 82 break;
7682 }
7683 20992 }
7684
7685
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 7)
7686 {
7687
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7688 {
7689 case iStoneAgony:
7690 case iStompBoots:
7691 case iPerilRing:
7692 case iWhimsicalRing:
7693 {
7694 328 reset_itembuf(&tempitem, i);
7695 328 strcpy(item_string[i],old_item_string[i]);
7696 328 break;
7697 }
7698 }
7699 20992 }
7700
7701
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 8) // May 2007: Some corrections.
7702 {
7703
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7704 {
7705 case iMShield:
7706 82 tempitem.misc1|=sh_flame;
7707 82 tempitem.misc2|=sh_fireball|sh_magic;
7708
7709
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7710 {
7711 tempitem.misc2 |= sh_sword;
7712 }
7713
7714 // fallthrough
7715 case iShield:
7716 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7717
7718 // fallthrough
7719 case iSShield:
7720 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7721
7722
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7723 {
7724 tempitem.misc2 |= sh_rock;
7725 }
7726
7727 246 break;
7728
7729 case iWhispRing:
7730 82 tempitem.power=1;
7731 82 tempitem.flags|=item_gamedata|item_flag1;
7732 82 tempitem.misc1 = 3;
7733 82 break;
7734
7735 case iL2WhispRing:
7736 82 tempitem.power=0;
7737 82 tempitem.flags|=item_gamedata|item_flag1;
7738 82 tempitem.misc1 = 3;
7739 82 break;
7740
7741 case iL2Ladder:
7742 case iBow:
7743 case iCByrna:
7744 246 tempitem.power = 1;
7745 246 break;
7746 }
7747 20992 }
7748
7749
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 9 && i==iClock)
7750 {
7751 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7752 82 }
7753
7754 //add the misc flag for bomb
7755
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 10 && tempitem.type == itype_bomb)
7756 {
7757 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7758 82 }
7759
7760
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
127232 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7761 {
7762 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7763 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7764 164 }
7765
7766
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 12) // June 2007: More Misc. attributes.
7767 {
7768
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7769 {
7770 case iFBrang:
7771 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7772
7773 //fallthrough
7774 case iMBrang:
7775 164 tempitem.misc3 |= sh_sword|sh_magic;
7776
7777 //fallthrough
7778 case iHookshot:
7779 case iLongshot:
7780 //fallthrough
7781 328 tempitem.misc3 |= sh_fireball;
7782
7783 case iBrang:
7784 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7785 410 break;
7786 }
7787
7788
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 328 times.
✓ Branch 10 taken 164 times.
✓ Branch 11 taken 9629 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7789 {
7790 case itype_hoverboots:
7791 82 tempitem.usesound = WAV_ZN1HOVER;
7792 82 break;
7793
7794 case itype_wand:
7795 82 tempitem.usesound = WAV_WAND;
7796 82 break;
7797
7798 case itype_book:
7799 82 tempitem.usesound = WAV_FIRE;
7800 82 break;
7801
7802 case itype_arrow:
7803 246 tempitem.usesound = WAV_ARROW;
7804 246 break;
7805
7806 case itype_hookshot:
7807 164 tempitem.usesound = WAV_HOOKSHOT;
7808 164 break;
7809
7810 case itype_brang:
7811 246 tempitem.usesound = WAV_BRANG;
7812 246 break;
7813
7814 case itype_shield:
7815 246 tempitem.usesound = WAV_CHINK;
7816 246 break;
7817
7818 case itype_sword:
7819 9313 tempitem.usesound = WAV_SWORD;
7820 9313 break;
7821
7822 case itype_whistle:
7823 82 tempitem.usesound = WAV_WHISTLE;
7824 82 break;
7825
7826 case itype_hammer:
7827 82 tempitem.usesound = WAV_HAMMER;
7828 82 break;
7829
7830 case itype_divinefire:
7831 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7832 82 break;
7833
7834 case itype_divineescape:
7835 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7836 82 break;
7837
7838 case itype_divineprotection:
7839 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7840 82 break;
7841
7842 case itype_bomb:
7843 case itype_sbomb:
7844 case itype_quakescroll:
7845 case itype_quakescroll2:
7846 328 tempitem.usesound = WAV_BOMB;
7847 328 break;
7848
7849 case itype_spinscroll:
7850 case itype_spinscroll2:
7851 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7852 164 break;
7853 }
7854 20992 }
7855
7856
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 13) // July 2007
7857 {
7858
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7859 {
7860 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7861 82 tempitem.power = 1;
7862 82 tempitem.flags|=item_flag1;
7863 82 }
7864
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7865 82 tempitem.flags|=item_flag1;
7866
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7867 {
7868 82 tempitem.flags|=item_flag1;
7869 82 tempitem.power = 2;
7870 82 }
7871 20992 }
7872
7873
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 14) // August 2007
7874 {
7875
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7876 {
7877 164 tempitem.usesound = WAV_SCALE;
7878
7879
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7880 164 tempitem.misc3=50;
7881 164 }
7882
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7883 {
7884 164 tempitem.flags |= item_gain_old;
7885 164 }
7886 20992 }
7887
7888
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 17) // November 2007
7889 {
7890
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7891 {
7892 tempitem.wpn3 = wFIRE;
7893 }
7894
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7895 {
7896 82 tempitem.flags|=item_flag1;
7897 82 }
7898 20992 }
7899
7900
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 18) // New Year's Eve 2007
7901 {
7902
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7903 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7904
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7905 82 tempitem.misc1 = 768; // Frames until it goes
7906
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7907 {
7908
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7909 {
7910 82 tempitem.misc2 = 1; // Cutscene 1
7911 82 tempitem.flags |= item_flag1; // Side Warp Out
7912 82 }
7913 164 }
7914 20992 }
7915
7916
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 19) // January 2008
7917 {
7918
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7919 {
7920
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7921
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7922 82 }
7923 20992 }
7924
7925
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 20) // October 2008
7926 {
7927
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7928 {
7929 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7930 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7931 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7932 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7933 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7934 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7935 82 }
7936 20992 }
7937
7938
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 21) // November 2008
7939 {
7940
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7941 {
7942 tempitem.flags &= ~item_unused;
7943
7944 if(tempitem.type == itype_sword ||
7945 tempitem.type == itype_wand ||
7946 tempitem.type == itype_candle ||
7947 tempitem.type == itype_cbyrna)
7948 {
7949 tempitem.flags |= item_flag4;
7950 }
7951 }
7952 20992 }
7953
7954
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 22) // September 2009
7955 {
7956
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7957 {
7958 164 tempitem.misc3 = tempitem.power/2;
7959 164 }
7960 20992 }
7961
7962
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 23) // March 2011
7963 {
7964
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7965 82 tempitem.wpn5 = wFIRE;
7966
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7967 82 tempitem.wpn2 = wFIRE;
7968 20992 }
7969
7970 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7971 // whether it was or not, and a lot of existing quests depended on the
7972 // incorrect behavior.
7973
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 25) // January 2012
7974 {
7975
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7976 328 tempitem.flags |= item_flag1;
7977
7978
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7979 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7980 20992 }
7981
7982
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7983 {
7984
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7985 {
7986 case itype_sword:
7987 {
7988 17547 tempitem.flags &= ~(item_flag5);
7989 17547 tempitem.misc3 = 0;
7990 17547 tempitem.misc4 = 0;
7991 17547 tempitem.misc5 = 0;
7992 17547 tempitem.misc6 = 0;
7993 17547 tempitem.misc7 = 0;
7994 17547 tempitem.misc8 = 0;
7995 17547 tempitem.misc9 = 0;
7996 17547 tempitem.misc10 = 0;
7997 17547 tempitem.wpn4 = 0;
7998 17547 tempitem.wpn5 = 0;
7999 17547 tempitem.wpn6 = 0;
8000 17547 tempitem.wpn7 = 0;
8001 17547 tempitem.wpn8 = 0;
8002 17547 tempitem.wpn9 = 0;
8003 17547 tempitem.wpn10 = 0;
8004 17547 break;
8005 }
8006 case itype_brang:
8007 {
8008 844 tempitem.flags &= ~(item_flag4 | item_flag5);
8009 844 tempitem.misc2 = 0;
8010 844 tempitem.misc5 = 0;
8011 844 tempitem.misc6 = 0;
8012 844 tempitem.misc7 = 0;
8013 844 tempitem.misc8 = 0;
8014 844 tempitem.misc9 = 0;
8015 844 tempitem.misc10 = 0;
8016 844 tempitem.wpn4 = 0;
8017 844 tempitem.wpn5 = 0;
8018 844 tempitem.wpn6 = 0;
8019 844 tempitem.wpn7 = 0;
8020 844 tempitem.wpn8 = 0;
8021 844 tempitem.wpn9 = 0;
8022 844 tempitem.wpn10 = 0;
8023 844 break;
8024 }
8025 case itype_arrow:
8026 {
8027 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8028 831 tempitem.misc2 = 0;
8029 831 tempitem.misc3 = 0;
8030 831 tempitem.misc4 = 0;
8031 831 tempitem.misc5 = 0;
8032 831 tempitem.misc6 = 0;
8033 831 tempitem.misc7 = 0;
8034 831 tempitem.misc8 = 0;
8035 831 tempitem.misc9 = 0;
8036 831 tempitem.misc10 = 0;
8037 831 tempitem.wpn4 = 0;
8038 831 tempitem.wpn5 = 0;
8039 831 tempitem.wpn6 = 0;
8040 831 tempitem.wpn7 = 0;
8041 831 tempitem.wpn8 = 0;
8042 831 tempitem.wpn9 = 0;
8043 831 tempitem.wpn10 = 0;
8044 831 break;
8045 }
8046 case itype_candle:
8047 {
8048 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
8049 600 tempitem.misc1 = 0;
8050 600 tempitem.misc2 = 0;
8051 600 tempitem.misc3 = 0;
8052 600 tempitem.misc4 = 0;
8053 600 tempitem.misc5 = 0;
8054 600 tempitem.misc6 = 0;
8055 600 tempitem.misc7 = 0;
8056 600 tempitem.misc8 = 0;
8057 600 tempitem.misc9 = 0;
8058 600 tempitem.misc10 = 0;
8059 600 tempitem.wpn4 = 0;
8060 600 tempitem.wpn5 = 0;
8061 600 tempitem.wpn6 = 0;
8062 600 tempitem.wpn7 = 0;
8063 600 tempitem.wpn8 = 0;
8064 600 tempitem.wpn9 = 0;
8065 600 tempitem.wpn10 = 0;
8066 600 break;
8067 }
8068 case itype_whistle:
8069 {
8070 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8071 327 tempitem.misc3 = 0;
8072 327 tempitem.misc4 = 0;
8073 327 tempitem.misc5 = 0;
8074 327 tempitem.misc6 = 0;
8075 327 tempitem.misc7 = 0;
8076 327 tempitem.misc8 = 0;
8077 327 tempitem.misc9 = 0;
8078 327 tempitem.misc10 = 0;
8079 327 tempitem.wpn2 = 0;
8080 327 tempitem.wpn3 = 0;
8081 327 tempitem.wpn4 = 0;
8082 327 tempitem.wpn5 = 0;
8083 327 tempitem.wpn6 = 0;
8084 327 tempitem.wpn7 = 0;
8085 327 tempitem.wpn8 = 0;
8086 327 tempitem.wpn9 = 0;
8087 327 tempitem.wpn10 = 0;
8088 327 break;
8089 }
8090 case itype_bait:
8091 {
8092 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8093 282 tempitem.misc2 = 0;
8094 282 tempitem.misc3 = 0;
8095 282 tempitem.misc4 = 0;
8096 282 tempitem.misc5 = 0;
8097 282 tempitem.misc6 = 0;
8098 282 tempitem.misc7 = 0;
8099 282 tempitem.misc8 = 0;
8100 282 tempitem.misc9 = 0;
8101 282 tempitem.misc10 = 0;
8102 282 tempitem.wpn2 = 0;
8103 282 tempitem.wpn3 = 0;
8104 282 tempitem.wpn4 = 0;
8105 282 tempitem.wpn5 = 0;
8106 282 tempitem.wpn6 = 0;
8107 282 tempitem.wpn7 = 0;
8108 282 tempitem.wpn8 = 0;
8109 282 tempitem.wpn9 = 0;
8110 282 tempitem.wpn10 = 0;
8111 282 break;
8112 }
8113 case itype_letter:
8114 {
8115 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8116 558 tempitem.misc1 = 0;
8117 558 tempitem.misc2 = 0;
8118 558 tempitem.misc3 = 0;
8119 558 tempitem.misc4 = 0;
8120 558 tempitem.misc5 = 0;
8121 558 tempitem.misc6 = 0;
8122 558 tempitem.misc7 = 0;
8123 558 tempitem.misc8 = 0;
8124 558 tempitem.misc9 = 0;
8125 558 tempitem.misc10 = 0;
8126 558 tempitem.wpn = 0;
8127 558 tempitem.wpn2 = 0;
8128 558 tempitem.wpn3 = 0;
8129 558 tempitem.wpn4 = 0;
8130 558 tempitem.wpn5 = 0;
8131 558 tempitem.wpn6 = 0;
8132 558 tempitem.wpn7 = 0;
8133 558 tempitem.wpn8 = 0;
8134 558 tempitem.wpn9 = 0;
8135 558 tempitem.wpn10 = 0;
8136 558 break;
8137 }
8138 case itype_potion:
8139 {
8140 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8141 614 tempitem.misc3 = 0;
8142 614 tempitem.misc4 = 0;
8143 614 tempitem.misc5 = 0;
8144 614 tempitem.misc6 = 0;
8145 614 tempitem.misc7 = 0;
8146 614 tempitem.misc8 = 0;
8147 614 tempitem.misc9 = 0;
8148 614 tempitem.misc10 = 0;
8149 614 tempitem.wpn = 0;
8150 614 tempitem.wpn2 = 0;
8151 614 tempitem.wpn3 = 0;
8152 614 tempitem.wpn4 = 0;
8153 614 tempitem.wpn5 = 0;
8154 614 tempitem.wpn6 = 0;
8155 614 tempitem.wpn7 = 0;
8156 614 tempitem.wpn8 = 0;
8157 614 tempitem.wpn9 = 0;
8158 614 tempitem.wpn10 = 0;
8159 614 break;
8160 }
8161 case itype_wand:
8162 {
8163 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8164 297 tempitem.misc1 = 0;
8165 297 tempitem.misc2 = 0;
8166 297 tempitem.misc3 = 0;
8167 297 tempitem.misc4 = 0;
8168 297 tempitem.misc5 = 0;
8169 297 tempitem.misc6 = 0;
8170 297 tempitem.misc7 = 0;
8171 297 tempitem.misc8 = 0;
8172 297 tempitem.misc9 = 0;
8173 297 tempitem.misc10 = 0;
8174 297 tempitem.wpn4 = 0;
8175 297 tempitem.wpn5 = 0;
8176 297 tempitem.wpn6 = 0;
8177 297 tempitem.wpn7 = 0;
8178 297 tempitem.wpn8 = 0;
8179 297 tempitem.wpn9 = 0;
8180 297 tempitem.wpn10 = 0;
8181 297 break;
8182 }
8183 case itype_ring:
8184 {
8185 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8186 917 tempitem.misc2 = 0;
8187 917 tempitem.misc3 = 0;
8188 917 tempitem.misc4 = 0;
8189 917 tempitem.misc5 = 0;
8190 917 tempitem.misc6 = 0;
8191 917 tempitem.misc7 = 0;
8192 917 tempitem.misc8 = 0;
8193 917 tempitem.misc9 = 0;
8194 917 tempitem.misc10 = 0;
8195 917 tempitem.wpn = 0;
8196 917 tempitem.wpn2 = 0;
8197 917 tempitem.wpn3 = 0;
8198 917 tempitem.wpn4 = 0;
8199 917 tempitem.wpn5 = 0;
8200 917 tempitem.wpn6 = 0;
8201 917 tempitem.wpn7 = 0;
8202 917 tempitem.wpn8 = 0;
8203 917 tempitem.wpn9 = 0;
8204 917 tempitem.wpn10 = 0;
8205 917 break;
8206 }
8207 case itype_wallet:
8208 {
8209 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8210 892 tempitem.misc3 = 0;
8211 892 tempitem.misc4 = 0;
8212 892 tempitem.misc5 = 0;
8213 892 tempitem.misc6 = 0;
8214 892 tempitem.misc7 = 0;
8215 892 tempitem.misc8 = 0;
8216 892 tempitem.misc9 = 0;
8217 892 tempitem.misc10 = 0;
8218 892 tempitem.wpn = 0;
8219 892 tempitem.wpn2 = 0;
8220 892 tempitem.wpn3 = 0;
8221 892 tempitem.wpn4 = 0;
8222 892 tempitem.wpn5 = 0;
8223 892 tempitem.wpn6 = 0;
8224 892 tempitem.wpn7 = 0;
8225 892 tempitem.wpn8 = 0;
8226 892 tempitem.wpn9 = 0;
8227 892 tempitem.wpn10 = 0;
8228 892 break;
8229 }
8230 case itype_amulet:
8231 {
8232 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8233 557 tempitem.misc1 = 0;
8234 557 tempitem.misc2 = 0;
8235 557 tempitem.misc3 = 0;
8236 557 tempitem.misc4 = 0;
8237 557 tempitem.misc5 = 0;
8238 557 tempitem.misc6 = 0;
8239 557 tempitem.misc7 = 0;
8240 557 tempitem.misc8 = 0;
8241 557 tempitem.misc9 = 0;
8242 557 tempitem.misc10 = 0;
8243 557 tempitem.wpn = 0;
8244 557 tempitem.wpn2 = 0;
8245 557 tempitem.wpn3 = 0;
8246 557 tempitem.wpn4 = 0;
8247 557 tempitem.wpn5 = 0;
8248 557 tempitem.wpn6 = 0;
8249 557 tempitem.wpn7 = 0;
8250 557 tempitem.wpn8 = 0;
8251 557 tempitem.wpn9 = 0;
8252 557 tempitem.wpn10 = 0;
8253 557 break;
8254 }
8255 case itype_shield:
8256 {
8257 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8258 858 tempitem.misc3 = 0;
8259 858 tempitem.misc4 = 0;
8260 858 tempitem.misc5 = 0;
8261 858 tempitem.misc6 = 0;
8262 858 tempitem.misc7 = 0;
8263 858 tempitem.misc8 = 0;
8264 858 tempitem.misc9 = 0;
8265 858 tempitem.misc10 = 0;
8266 858 tempitem.wpn = 0;
8267 858 tempitem.wpn2 = 0;
8268 858 tempitem.wpn3 = 0;
8269 858 tempitem.wpn4 = 0;
8270 858 tempitem.wpn5 = 0;
8271 858 tempitem.wpn6 = 0;
8272 858 tempitem.wpn7 = 0;
8273 858 tempitem.wpn8 = 0;
8274 858 tempitem.wpn9 = 0;
8275 858 tempitem.wpn10 = 0;
8276 858 break;
8277 }
8278 case itype_bow:
8279 {
8280 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8281 558 tempitem.misc1 = 0;
8282 558 tempitem.misc2 = 0;
8283 558 tempitem.misc3 = 0;
8284 558 tempitem.misc4 = 0;
8285 558 tempitem.misc5 = 0;
8286 558 tempitem.misc6 = 0;
8287 558 tempitem.misc7 = 0;
8288 558 tempitem.misc8 = 0;
8289 558 tempitem.misc9 = 0;
8290 558 tempitem.misc10 = 0;
8291 558 tempitem.wpn = 0;
8292 558 tempitem.wpn2 = 0;
8293 558 tempitem.wpn3 = 0;
8294 558 tempitem.wpn4 = 0;
8295 558 tempitem.wpn5 = 0;
8296 558 tempitem.wpn6 = 0;
8297 558 tempitem.wpn7 = 0;
8298 558 tempitem.wpn8 = 0;
8299 558 tempitem.wpn9 = 0;
8300 558 tempitem.wpn10 = 0;
8301 558 break;
8302 }
8303 case itype_raft:
8304 {
8305 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8306 279 tempitem.misc1 = 0;
8307 279 tempitem.misc2 = 0;
8308 279 tempitem.misc3 = 0;
8309 279 tempitem.misc4 = 0;
8310 279 tempitem.misc5 = 0;
8311 279 tempitem.misc6 = 0;
8312 279 tempitem.misc7 = 0;
8313 279 tempitem.misc8 = 0;
8314 279 tempitem.misc9 = 0;
8315 279 tempitem.misc10 = 0;
8316 279 tempitem.wpn = 0;
8317 279 tempitem.wpn2 = 0;
8318 279 tempitem.wpn3 = 0;
8319 279 tempitem.wpn4 = 0;
8320 279 tempitem.wpn5 = 0;
8321 279 tempitem.wpn6 = 0;
8322 279 tempitem.wpn7 = 0;
8323 279 tempitem.wpn8 = 0;
8324 279 tempitem.wpn9 = 0;
8325 279 tempitem.wpn10 = 0;
8326 279 break;
8327 }
8328 case itype_ladder:
8329 {
8330 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8331 558 tempitem.misc1 = 0;
8332 558 tempitem.misc2 = 0;
8333 558 tempitem.misc3 = 0;
8334 558 tempitem.misc4 = 0;
8335 558 tempitem.misc5 = 0;
8336 558 tempitem.misc6 = 0;
8337 558 tempitem.misc7 = 0;
8338 558 tempitem.misc8 = 0;
8339 558 tempitem.misc9 = 0;
8340 558 tempitem.misc10 = 0;
8341 558 tempitem.wpn = 0;
8342 558 tempitem.wpn2 = 0;
8343 558 tempitem.wpn3 = 0;
8344 558 tempitem.wpn4 = 0;
8345 558 tempitem.wpn5 = 0;
8346 558 tempitem.wpn6 = 0;
8347 558 tempitem.wpn7 = 0;
8348 558 tempitem.wpn8 = 0;
8349 558 tempitem.wpn9 = 0;
8350 558 tempitem.wpn10 = 0;
8351 558 break;
8352 }
8353 case itype_book:
8354 {
8355 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8356 295 tempitem.misc1 = 0;
8357 295 tempitem.misc2 = 0;
8358 295 tempitem.misc3 = 0;
8359 295 tempitem.misc4 = 0;
8360 295 tempitem.misc5 = 0;
8361 295 tempitem.misc6 = 0;
8362 295 tempitem.misc7 = 0;
8363 295 tempitem.misc8 = 0;
8364 295 tempitem.misc9 = 0;
8365 295 tempitem.misc10 = 0;
8366 295 tempitem.wpn3 = 0;
8367 295 tempitem.wpn4 = 0;
8368 295 tempitem.wpn5 = 0;
8369 295 tempitem.wpn6 = 0;
8370 295 tempitem.wpn7 = 0;
8371 295 tempitem.wpn8 = 0;
8372 295 tempitem.wpn9 = 0;
8373 295 tempitem.wpn10 = 0;
8374 295 break;
8375 }
8376 case itype_magickey:
8377 {
8378 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8379 279 tempitem.misc1 = 0;
8380 279 tempitem.misc2 = 0;
8381 279 tempitem.misc3 = 0;
8382 279 tempitem.misc4 = 0;
8383 279 tempitem.misc5 = 0;
8384 279 tempitem.misc6 = 0;
8385 279 tempitem.misc7 = 0;
8386 279 tempitem.misc8 = 0;
8387 279 tempitem.misc9 = 0;
8388 279 tempitem.misc10 = 0;
8389 279 tempitem.wpn = 0;
8390 279 tempitem.wpn2 = 0;
8391 279 tempitem.wpn3 = 0;
8392 279 tempitem.wpn4 = 0;
8393 279 tempitem.wpn5 = 0;
8394 279 tempitem.wpn6 = 0;
8395 279 tempitem.wpn7 = 0;
8396 279 tempitem.wpn8 = 0;
8397 279 tempitem.wpn9 = 0;
8398 279 tempitem.wpn10 = 0;
8399 279 break;
8400 }
8401 case itype_bracelet:
8402 {
8403 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8404 846 tempitem.misc1 = 0;
8405 846 tempitem.misc2 = 0;
8406 846 tempitem.misc3 = 0;
8407 846 tempitem.misc4 = 0;
8408 846 tempitem.misc5 = 0;
8409 846 tempitem.misc6 = 0;
8410 846 tempitem.misc7 = 0;
8411 846 tempitem.misc8 = 0;
8412 846 tempitem.misc9 = 0;
8413 846 tempitem.misc10 = 0;
8414 846 tempitem.wpn = 0;
8415 846 tempitem.wpn2 = 0;
8416 846 tempitem.wpn3 = 0;
8417 846 tempitem.wpn4 = 0;
8418 846 tempitem.wpn5 = 0;
8419 846 tempitem.wpn6 = 0;
8420 846 tempitem.wpn7 = 0;
8421 846 tempitem.wpn8 = 0;
8422 846 tempitem.wpn9 = 0;
8423 846 tempitem.wpn10 = 0;
8424 846 break;
8425 }
8426 case itype_flippers:
8427 {
8428 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8429 282 tempitem.misc1 = 0;
8430 282 tempitem.misc2 = 0;
8431 282 tempitem.misc3 = 0;
8432 282 tempitem.misc4 = 0;
8433 282 tempitem.misc5 = 0;
8434 282 tempitem.misc6 = 0;
8435 282 tempitem.misc7 = 0;
8436 282 tempitem.misc8 = 0;
8437 282 tempitem.misc9 = 0;
8438 282 tempitem.misc10 = 0;
8439 282 tempitem.wpn = 0;
8440 282 tempitem.wpn2 = 0;
8441 282 tempitem.wpn3 = 0;
8442 282 tempitem.wpn4 = 0;
8443 282 tempitem.wpn5 = 0;
8444 282 tempitem.wpn6 = 0;
8445 282 tempitem.wpn7 = 0;
8446 282 tempitem.wpn8 = 0;
8447 282 tempitem.wpn9 = 0;
8448 282 tempitem.wpn10 = 0;
8449 282 break;
8450 }
8451 case itype_boots:
8452 {
8453 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8454 285 tempitem.misc1 = 0;
8455 285 tempitem.misc2 = 0;
8456 285 tempitem.misc3 = 0;
8457 285 tempitem.misc4 = 0;
8458 285 tempitem.misc5 = 0;
8459 285 tempitem.misc6 = 0;
8460 285 tempitem.misc7 = 0;
8461 285 tempitem.misc8 = 0;
8462 285 tempitem.misc9 = 0;
8463 285 tempitem.misc10 = 0;
8464 285 tempitem.wpn = 0;
8465 285 tempitem.wpn2 = 0;
8466 285 tempitem.wpn3 = 0;
8467 285 tempitem.wpn4 = 0;
8468 285 tempitem.wpn5 = 0;
8469 285 tempitem.wpn6 = 0;
8470 285 tempitem.wpn7 = 0;
8471 285 tempitem.wpn8 = 0;
8472 285 tempitem.wpn9 = 0;
8473 285 tempitem.wpn10 = 0;
8474 285 break;
8475 }
8476 case itype_hookshot:
8477 {
8478 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8479 560 tempitem.misc5 = 0;
8480 560 tempitem.misc6 = 0;
8481 560 tempitem.misc7 = 0;
8482 560 tempitem.misc8 = 0;
8483 560 tempitem.misc9 = 0;
8484 560 tempitem.misc10 = 0;
8485 560 tempitem.wpn5 = 0;
8486 560 tempitem.wpn6 = 0;
8487 560 tempitem.wpn7 = 0;
8488 560 tempitem.wpn8 = 0;
8489 560 tempitem.wpn9 = 0;
8490 560 tempitem.wpn10 = 0;
8491 560 break;
8492 }
8493 case itype_lens:
8494 {
8495 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8496 255 tempitem.misc2 = 0;
8497 255 tempitem.misc3 = 0;
8498 255 tempitem.misc4 = 0;
8499 255 tempitem.misc5 = 0;
8500 255 tempitem.misc6 = 0;
8501 255 tempitem.misc7 = 0;
8502 255 tempitem.misc8 = 0;
8503 255 tempitem.misc9 = 0;
8504 255 tempitem.misc10 = 0;
8505 255 tempitem.wpn = 0;
8506 255 tempitem.wpn2 = 0;
8507 255 tempitem.wpn3 = 0;
8508 255 tempitem.wpn4 = 0;
8509 255 tempitem.wpn5 = 0;
8510 255 tempitem.wpn6 = 0;
8511 255 tempitem.wpn7 = 0;
8512 255 tempitem.wpn8 = 0;
8513 255 tempitem.wpn9 = 0;
8514 255 tempitem.wpn10 = 0;
8515 255 break;
8516 }
8517 case itype_hammer:
8518 {
8519 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8520 282 tempitem.misc1 = 0;
8521 282 tempitem.misc2 = 0;
8522 282 tempitem.misc3 = 0;
8523 282 tempitem.misc4 = 0;
8524 282 tempitem.misc5 = 0;
8525 282 tempitem.misc6 = 0;
8526 282 tempitem.misc7 = 0;
8527 282 tempitem.misc8 = 0;
8528 282 tempitem.misc9 = 0;
8529 282 tempitem.misc10 = 0;
8530 282 tempitem.wpn3 = 0;
8531 282 tempitem.wpn4 = 0;
8532 282 tempitem.wpn5 = 0;
8533 282 tempitem.wpn6 = 0;
8534 282 tempitem.wpn7 = 0;
8535 282 tempitem.wpn8 = 0;
8536 282 tempitem.wpn9 = 0;
8537 282 tempitem.wpn10 = 0;
8538 282 break;
8539 }
8540 case itype_divinefire:
8541 {
8542 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8543 279 tempitem.misc3 = 0;
8544 279 tempitem.misc4 = 0;
8545 279 tempitem.misc5 = 0;
8546 279 tempitem.misc6 = 0;
8547 279 tempitem.misc7 = 0;
8548 279 tempitem.misc8 = 0;
8549 279 tempitem.misc9 = 0;
8550 279 tempitem.misc10 = 0;
8551 279 tempitem.wpn6 = 0;
8552 279 tempitem.wpn7 = 0;
8553 279 tempitem.wpn8 = 0;
8554 279 tempitem.wpn9 = 0;
8555 279 tempitem.wpn10 = 0;
8556 279 break;
8557 }
8558 case itype_divineescape:
8559 {
8560 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8561 279 tempitem.misc2 = 0;
8562 279 tempitem.misc3 = 0;
8563 279 tempitem.misc4 = 0;
8564 279 tempitem.misc5 = 0;
8565 279 tempitem.misc6 = 0;
8566 279 tempitem.misc7 = 0;
8567 279 tempitem.misc8 = 0;
8568 279 tempitem.misc9 = 0;
8569 279 tempitem.misc10 = 0;
8570 279 tempitem.wpn = 0;
8571 279 tempitem.wpn2 = 0;
8572 279 tempitem.wpn3 = 0;
8573 279 tempitem.wpn4 = 0;
8574 279 tempitem.wpn5 = 0;
8575 279 tempitem.wpn6 = 0;
8576 279 tempitem.wpn7 = 0;
8577 279 tempitem.wpn8 = 0;
8578 279 tempitem.wpn9 = 0;
8579 279 tempitem.wpn10 = 0;
8580 279 break;
8581 }
8582 case itype_divineprotection:
8583 {
8584 279 tempitem.flags &= ~ (item_flag5);
8585 279 tempitem.misc2 = 0;
8586 279 tempitem.misc3 = 0;
8587 279 tempitem.misc4 = 0;
8588 279 tempitem.misc5 = 0;
8589 279 tempitem.misc6 = 0;
8590 279 tempitem.misc7 = 0;
8591 279 tempitem.misc8 = 0;
8592 279 tempitem.misc9 = 0;
8593 279 tempitem.misc10 = 0;
8594 279 break;
8595 }
8596 case itype_bomb:
8597 {
8598 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8599 295 tempitem.misc4 = 0;
8600 295 tempitem.misc5 = 0;
8601 295 tempitem.misc6 = 0;
8602 295 tempitem.misc7 = 0;
8603 295 tempitem.misc8 = 0;
8604 295 tempitem.misc9 = 0;
8605 295 tempitem.misc10 = 0;
8606 295 tempitem.wpn3 = 0;
8607 295 tempitem.wpn4 = 0;
8608 295 tempitem.wpn5 = 0;
8609 295 tempitem.wpn6 = 0;
8610 295 tempitem.wpn7 = 0;
8611 295 tempitem.wpn8 = 0;
8612 295 tempitem.wpn9 = 0;
8613 295 tempitem.wpn10 = 0;
8614 295 break;
8615 }
8616 case itype_sbomb:
8617 {
8618 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8619 281 tempitem.misc4 = 0;
8620 281 tempitem.misc5 = 0;
8621 281 tempitem.misc6 = 0;
8622 281 tempitem.misc7 = 0;
8623 281 tempitem.misc8 = 0;
8624 281 tempitem.misc9 = 0;
8625 281 tempitem.misc10 = 0;
8626 281 tempitem.wpn3 = 0;
8627 281 tempitem.wpn4 = 0;
8628 281 tempitem.wpn5 = 0;
8629 281 tempitem.wpn6 = 0;
8630 281 tempitem.wpn7 = 0;
8631 281 tempitem.wpn8 = 0;
8632 281 tempitem.wpn9 = 0;
8633 281 tempitem.wpn10 = 0;
8634 281 break;
8635 }
8636 case itype_clock:
8637 {
8638 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8639 282 tempitem.misc2 = 0;
8640 282 tempitem.misc3 = 0;
8641 282 tempitem.misc4 = 0;
8642 282 tempitem.misc5 = 0;
8643 282 tempitem.misc6 = 0;
8644 282 tempitem.misc7 = 0;
8645 282 tempitem.misc8 = 0;
8646 282 tempitem.misc9 = 0;
8647 282 tempitem.misc10 = 0;
8648 282 tempitem.wpn = 0;
8649 282 tempitem.wpn2 = 0;
8650 282 tempitem.wpn3 = 0;
8651 282 tempitem.wpn4 = 0;
8652 282 tempitem.wpn5 = 0;
8653 282 tempitem.wpn6 = 0;
8654 282 tempitem.wpn7 = 0;
8655 282 tempitem.wpn8 = 0;
8656 282 tempitem.wpn9 = 0;
8657 282 tempitem.wpn10 = 0;
8658 282 break;
8659 }
8660 case itype_key:
8661 {
8662 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8663 279 tempitem.misc1 = 0;
8664 279 tempitem.misc2 = 0;
8665 279 tempitem.misc3 = 0;
8666 279 tempitem.misc4 = 0;
8667 279 tempitem.misc5 = 0;
8668 279 tempitem.misc6 = 0;
8669 279 tempitem.misc7 = 0;
8670 279 tempitem.misc8 = 0;
8671 279 tempitem.misc9 = 0;
8672 279 tempitem.misc10 = 0;
8673 279 tempitem.wpn = 0;
8674 279 tempitem.wpn2 = 0;
8675 279 tempitem.wpn3 = 0;
8676 279 tempitem.wpn4 = 0;
8677 279 tempitem.wpn5 = 0;
8678 279 tempitem.wpn6 = 0;
8679 279 tempitem.wpn7 = 0;
8680 279 tempitem.wpn8 = 0;
8681 279 tempitem.wpn9 = 0;
8682 279 tempitem.wpn10 = 0;
8683 279 break;
8684 }
8685 case itype_magiccontainer:
8686 {
8687 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8688 284 tempitem.misc1 = 0;
8689 284 tempitem.misc2 = 0;
8690 284 tempitem.misc3 = 0;
8691 284 tempitem.misc4 = 0;
8692 284 tempitem.misc5 = 0;
8693 284 tempitem.misc6 = 0;
8694 284 tempitem.misc7 = 0;
8695 284 tempitem.misc8 = 0;
8696 284 tempitem.misc9 = 0;
8697 284 tempitem.misc10 = 0;
8698 284 tempitem.wpn = 0;
8699 284 tempitem.wpn2 = 0;
8700 284 tempitem.wpn3 = 0;
8701 284 tempitem.wpn4 = 0;
8702 284 tempitem.wpn5 = 0;
8703 284 tempitem.wpn6 = 0;
8704 284 tempitem.wpn7 = 0;
8705 284 tempitem.wpn8 = 0;
8706 284 tempitem.wpn9 = 0;
8707 284 tempitem.wpn10 = 0;
8708 284 break;
8709 }
8710 case itype_triforcepiece:
8711 {
8712 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8713 558 tempitem.misc3 = 0;
8714 558 tempitem.misc4 = 0;
8715 558 tempitem.misc5 = 0;
8716 558 tempitem.misc6 = 0;
8717 558 tempitem.misc7 = 0;
8718 558 tempitem.misc8 = 0;
8719 558 tempitem.misc9 = 0;
8720 558 tempitem.misc10 = 0;
8721 558 tempitem.wpn = 0;
8722 558 tempitem.wpn2 = 0;
8723 558 tempitem.wpn3 = 0;
8724 558 tempitem.wpn4 = 0;
8725 558 tempitem.wpn5 = 0;
8726 558 tempitem.wpn6 = 0;
8727 558 tempitem.wpn7 = 0;
8728 558 tempitem.wpn8 = 0;
8729 558 tempitem.wpn9 = 0;
8730 558 tempitem.wpn10 = 0;
8731 558 break;
8732 }
8733 case itype_map: case itype_compass: case itype_bosskey:
8734 {
8735 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8736 842 tempitem.misc1 = 0;
8737 842 tempitem.misc2 = 0;
8738 842 tempitem.misc3 = 0;
8739 842 tempitem.misc4 = 0;
8740 842 tempitem.misc5 = 0;
8741 842 tempitem.misc6 = 0;
8742 842 tempitem.misc7 = 0;
8743 842 tempitem.misc8 = 0;
8744 842 tempitem.misc9 = 0;
8745 842 tempitem.misc10 = 0;
8746 842 tempitem.wpn = 0;
8747 842 tempitem.wpn2 = 0;
8748 842 tempitem.wpn3 = 0;
8749 842 tempitem.wpn4 = 0;
8750 842 tempitem.wpn5 = 0;
8751 842 tempitem.wpn6 = 0;
8752 842 tempitem.wpn7 = 0;
8753 842 tempitem.wpn8 = 0;
8754 842 tempitem.wpn9 = 0;
8755 842 tempitem.wpn10 = 0;
8756 842 break;
8757 }
8758 case itype_quiver:
8759 {
8760 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8761 1116 tempitem.misc3 = 0;
8762 1116 tempitem.misc4 = 0;
8763 1116 tempitem.misc5 = 0;
8764 1116 tempitem.misc6 = 0;
8765 1116 tempitem.misc7 = 0;
8766 1116 tempitem.misc8 = 0;
8767 1116 tempitem.misc9 = 0;
8768 1116 tempitem.misc10 = 0;
8769 1116 tempitem.wpn = 0;
8770 1116 tempitem.wpn2 = 0;
8771 1116 tempitem.wpn3 = 0;
8772 1116 tempitem.wpn4 = 0;
8773 1116 tempitem.wpn5 = 0;
8774 1116 tempitem.wpn6 = 0;
8775 1116 tempitem.wpn7 = 0;
8776 1116 tempitem.wpn8 = 0;
8777 1116 tempitem.wpn9 = 0;
8778 1116 tempitem.wpn10 = 0;
8779 1116 break;
8780 }
8781 case itype_lkey:
8782 {
8783 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8784 780 tempitem.misc1 = 0;
8785 780 tempitem.misc2 = 0;
8786 780 tempitem.misc3 = 0;
8787 780 tempitem.misc4 = 0;
8788 780 tempitem.misc5 = 0;
8789 780 tempitem.misc6 = 0;
8790 780 tempitem.misc7 = 0;
8791 780 tempitem.misc8 = 0;
8792 780 tempitem.misc9 = 0;
8793 780 tempitem.misc10 = 0;
8794 780 tempitem.wpn = 0;
8795 780 tempitem.wpn2 = 0;
8796 780 tempitem.wpn3 = 0;
8797 780 tempitem.wpn4 = 0;
8798 780 tempitem.wpn5 = 0;
8799 780 tempitem.wpn6 = 0;
8800 780 tempitem.wpn7 = 0;
8801 780 tempitem.wpn8 = 0;
8802 780 tempitem.wpn9 = 0;
8803 780 tempitem.wpn10 = 0;
8804 780 break;
8805 }
8806 case itype_cbyrna:
8807 {
8808 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8809 279 tempitem.misc4 = 0;
8810 279 tempitem.misc5 = 0;
8811 279 tempitem.misc6 = 0;
8812 279 tempitem.misc7 = 0;
8813 279 tempitem.misc8 = 0;
8814 279 tempitem.misc9 = 0;
8815 279 tempitem.misc10 = 0;
8816 279 tempitem.wpn6 = 0;
8817 279 tempitem.wpn7 = 0;
8818 279 tempitem.wpn8 = 0;
8819 279 tempitem.wpn9 = 0;
8820 279 tempitem.wpn10 = 0;
8821 279 break;
8822 }
8823 case itype_rupee: case itype_arrowammo:
8824 {
8825 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8826 3261 tempitem.misc1 = 0;
8827 3261 tempitem.misc2 = 0;
8828 3261 tempitem.misc3 = 0;
8829 3261 tempitem.misc4 = 0;
8830 3261 tempitem.misc5 = 0;
8831 3261 tempitem.misc6 = 0;
8832 3261 tempitem.misc7 = 0;
8833 3261 tempitem.misc8 = 0;
8834 3261 tempitem.misc9 = 0;
8835 3261 tempitem.misc10 = 0;
8836 3261 tempitem.wpn = 0;
8837 3261 tempitem.wpn2 = 0;
8838 3261 tempitem.wpn3 = 0;
8839 3261 tempitem.wpn4 = 0;
8840 3261 tempitem.wpn5 = 0;
8841 3261 tempitem.wpn6 = 0;
8842 3261 tempitem.wpn7 = 0;
8843 3261 tempitem.wpn8 = 0;
8844 3261 tempitem.wpn9 = 0;
8845 3261 tempitem.wpn10 = 0;
8846 3261 break;
8847 }
8848 case itype_fairy:
8849 {
8850 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8851 545 tempitem.misc4 = 0;
8852 545 tempitem.misc5 = 0;
8853 545 tempitem.misc6 = 0;
8854 545 tempitem.misc7 = 0;
8855 545 tempitem.misc8 = 0;
8856 545 tempitem.misc9 = 0;
8857 545 tempitem.misc10 = 0;
8858 545 tempitem.wpn = 0;
8859 545 tempitem.wpn2 = 0;
8860 545 tempitem.wpn3 = 0;
8861 545 tempitem.wpn4 = 0;
8862 545 tempitem.wpn5 = 0;
8863 545 tempitem.wpn6 = 0;
8864 545 tempitem.wpn7 = 0;
8865 545 tempitem.wpn8 = 0;
8866 545 tempitem.wpn9 = 0;
8867 545 tempitem.wpn10 = 0;
8868 545 break;
8869 }
8870 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8871 {
8872 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8873 2872 tempitem.misc1 = 0;
8874 2872 tempitem.misc2 = 0;
8875 2872 tempitem.misc3 = 0;
8876 2872 tempitem.misc4 = 0;
8877 2872 tempitem.misc5 = 0;
8878 2872 tempitem.misc6 = 0;
8879 2872 tempitem.misc7 = 0;
8880 2872 tempitem.misc8 = 0;
8881 2872 tempitem.misc9 = 0;
8882 2872 tempitem.misc10 = 0;
8883 2872 tempitem.wpn = 0;
8884 2872 tempitem.wpn2 = 0;
8885 2872 tempitem.wpn3 = 0;
8886 2872 tempitem.wpn4 = 0;
8887 2872 tempitem.wpn5 = 0;
8888 2872 tempitem.wpn6 = 0;
8889 2872 tempitem.wpn7 = 0;
8890 2872 tempitem.wpn8 = 0;
8891 2872 tempitem.wpn9 = 0;
8892 2872 tempitem.wpn10 = 0;
8893 2872 break;
8894 }
8895 case itype_bombbag:
8896 {
8897 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8898 1116 tempitem.misc3 = 0;
8899 1116 tempitem.misc4 = 0;
8900 1116 tempitem.misc5 = 0;
8901 1116 tempitem.misc6 = 0;
8902 1116 tempitem.misc7 = 0;
8903 1116 tempitem.misc8 = 0;
8904 1116 tempitem.misc9 = 0;
8905 1116 tempitem.misc10 = 0;
8906 1116 tempitem.wpn = 0;
8907 1116 tempitem.wpn2 = 0;
8908 1116 tempitem.wpn3 = 0;
8909 1116 tempitem.wpn4 = 0;
8910 1116 tempitem.wpn5 = 0;
8911 1116 tempitem.wpn6 = 0;
8912 1116 tempitem.wpn7 = 0;
8913 1116 tempitem.wpn8 = 0;
8914 1116 tempitem.wpn9 = 0;
8915 1116 tempitem.wpn10 = 0;
8916 1116 break;
8917 }
8918 case itype_rocs:
8919 {
8920 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8921 279 tempitem.misc1 = 0;
8922 279 tempitem.misc2 = 0;
8923 279 tempitem.misc3 = 0;
8924 279 tempitem.misc4 = 0;
8925 279 tempitem.misc5 = 0;
8926 279 tempitem.misc6 = 0;
8927 279 tempitem.misc7 = 0;
8928 279 tempitem.misc8 = 0;
8929 279 tempitem.misc9 = 0;
8930 279 tempitem.misc10 = 0;
8931 279 tempitem.wpn = 0;
8932 279 tempitem.wpn2 = 0;
8933 279 tempitem.wpn3 = 0;
8934 279 tempitem.wpn4 = 0;
8935 279 tempitem.wpn5 = 0;
8936 279 tempitem.wpn6 = 0;
8937 279 tempitem.wpn7 = 0;
8938 279 tempitem.wpn8 = 0;
8939 279 tempitem.wpn9 = 0;
8940 279 tempitem.wpn10 = 0;
8941 279 break;
8942 }
8943 case itype_hoverboots:
8944 {
8945 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8946 279 tempitem.misc2 = 0;
8947 279 tempitem.misc3 = 0;
8948 279 tempitem.misc4 = 0;
8949 279 tempitem.misc5 = 0;
8950 279 tempitem.misc6 = 0;
8951 279 tempitem.misc7 = 0;
8952 279 tempitem.misc8 = 0;
8953 279 tempitem.misc9 = 0;
8954 279 tempitem.misc10 = 0;
8955 279 tempitem.wpn2 = 0;
8956 279 tempitem.wpn3 = 0;
8957 279 tempitem.wpn4 = 0;
8958 279 tempitem.wpn5 = 0;
8959 279 tempitem.wpn6 = 0;
8960 279 tempitem.wpn7 = 0;
8961 279 tempitem.wpn8 = 0;
8962 279 tempitem.wpn9 = 0;
8963 279 tempitem.wpn10 = 0;
8964 279 break;
8965 }
8966 case itype_spinscroll:
8967 {
8968 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8969 279 tempitem.misc2 = 0;
8970 279 tempitem.misc3 = 0;
8971 279 tempitem.misc4 = 0;
8972 279 tempitem.misc5 = 0;
8973 279 tempitem.misc6 = 0;
8974 279 tempitem.misc7 = 0;
8975 279 tempitem.misc8 = 0;
8976 279 tempitem.misc9 = 0;
8977 279 tempitem.misc10 = 0;
8978 279 tempitem.wpn = 0;
8979 279 tempitem.wpn2 = 0;
8980 279 tempitem.wpn3 = 0;
8981 279 tempitem.wpn4 = 0;
8982 279 tempitem.wpn5 = 0;
8983 279 tempitem.wpn6 = 0;
8984 279 tempitem.wpn7 = 0;
8985 279 tempitem.wpn8 = 0;
8986 279 tempitem.wpn9 = 0;
8987 279 tempitem.wpn10 = 0;
8988 279 break;
8989 }
8990 case itype_crossscroll:
8991 {
8992 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8993 279 tempitem.misc1 = 0;
8994 279 tempitem.misc2 = 0;
8995 279 tempitem.misc3 = 0;
8996 279 tempitem.misc4 = 0;
8997 279 tempitem.misc5 = 0;
8998 279 tempitem.misc6 = 0;
8999 279 tempitem.misc7 = 0;
9000 279 tempitem.misc8 = 0;
9001 279 tempitem.misc9 = 0;
9002 279 tempitem.misc10 = 0;
9003 279 tempitem.wpn = 0;
9004 279 tempitem.wpn2 = 0;
9005 279 tempitem.wpn3 = 0;
9006 279 tempitem.wpn4 = 0;
9007 279 tempitem.wpn5 = 0;
9008 279 tempitem.wpn6 = 0;
9009 279 tempitem.wpn7 = 0;
9010 279 tempitem.wpn8 = 0;
9011 279 tempitem.wpn9 = 0;
9012 279 tempitem.wpn10 = 0;
9013 279 break;
9014 }
9015 case itype_quakescroll:
9016 {
9017 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9018 279 tempitem.misc3 = 0;
9019 279 tempitem.misc4 = 0;
9020 279 tempitem.misc5 = 0;
9021 279 tempitem.misc6 = 0;
9022 279 tempitem.misc7 = 0;
9023 279 tempitem.misc8 = 0;
9024 279 tempitem.misc9 = 0;
9025 279 tempitem.misc10 = 0;
9026 279 tempitem.wpn = 0;
9027 279 tempitem.wpn2 = 0;
9028 279 tempitem.wpn3 = 0;
9029 279 tempitem.wpn4 = 0;
9030 279 tempitem.wpn5 = 0;
9031 279 tempitem.wpn6 = 0;
9032 279 tempitem.wpn7 = 0;
9033 279 tempitem.wpn8 = 0;
9034 279 tempitem.wpn9 = 0;
9035 279 tempitem.wpn10 = 0;
9036 279 break;
9037 }
9038 case itype_whispring:
9039 {
9040 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
9041 561 tempitem.misc2 = 0;
9042 561 tempitem.misc3 = 0;
9043 561 tempitem.misc4 = 0;
9044 561 tempitem.misc5 = 0;
9045 561 tempitem.misc6 = 0;
9046 561 tempitem.misc7 = 0;
9047 561 tempitem.misc8 = 0;
9048 561 tempitem.misc9 = 0;
9049 561 tempitem.misc10 = 0;
9050 561 tempitem.wpn = 0;
9051 561 tempitem.wpn2 = 0;
9052 561 tempitem.wpn3 = 0;
9053 561 tempitem.wpn4 = 0;
9054 561 tempitem.wpn5 = 0;
9055 561 tempitem.wpn6 = 0;
9056 561 tempitem.wpn7 = 0;
9057 561 tempitem.wpn8 = 0;
9058 561 tempitem.wpn9 = 0;
9059 561 tempitem.wpn10 = 0;
9060 561 break;
9061 }
9062 case itype_chargering:
9063 {
9064 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9065 558 tempitem.misc3 = 0;
9066 558 tempitem.misc4 = 0;
9067 558 tempitem.misc5 = 0;
9068 558 tempitem.misc6 = 0;
9069 558 tempitem.misc7 = 0;
9070 558 tempitem.misc8 = 0;
9071 558 tempitem.misc9 = 0;
9072 558 tempitem.misc10 = 0;
9073 558 tempitem.wpn = 0;
9074 558 tempitem.wpn2 = 0;
9075 558 tempitem.wpn3 = 0;
9076 558 tempitem.wpn4 = 0;
9077 558 tempitem.wpn5 = 0;
9078 558 tempitem.wpn6 = 0;
9079 558 tempitem.wpn7 = 0;
9080 558 tempitem.wpn8 = 0;
9081 558 tempitem.wpn9 = 0;
9082 558 tempitem.wpn10 = 0;
9083 558 break;
9084 }
9085 case itype_perilscroll:
9086 {
9087 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9088 279 tempitem.misc2 = 0;
9089 279 tempitem.misc3 = 0;
9090 279 tempitem.misc4 = 0;
9091 279 tempitem.misc5 = 0;
9092 279 tempitem.misc6 = 0;
9093 279 tempitem.misc7 = 0;
9094 279 tempitem.misc8 = 0;
9095 279 tempitem.misc9 = 0;
9096 279 tempitem.misc10 = 0;
9097 279 tempitem.wpn = 0;
9098 279 tempitem.wpn2 = 0;
9099 279 tempitem.wpn3 = 0;
9100 279 tempitem.wpn4 = 0;
9101 279 tempitem.wpn5 = 0;
9102 279 tempitem.wpn6 = 0;
9103 279 tempitem.wpn7 = 0;
9104 279 tempitem.wpn8 = 0;
9105 279 tempitem.wpn9 = 0;
9106 279 tempitem.wpn10 = 0;
9107 279 break;
9108 }
9109 case itype_wealthmedal:
9110 {
9111 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
9112 840 tempitem.misc2 = 0;
9113 840 tempitem.misc3 = 0;
9114 840 tempitem.misc4 = 0;
9115 840 tempitem.misc5 = 0;
9116 840 tempitem.misc6 = 0;
9117 840 tempitem.misc7 = 0;
9118 840 tempitem.misc8 = 0;
9119 840 tempitem.misc9 = 0;
9120 840 tempitem.misc10 = 0;
9121 840 tempitem.wpn = 0;
9122 840 tempitem.wpn2 = 0;
9123 840 tempitem.wpn3 = 0;
9124 840 tempitem.wpn4 = 0;
9125 840 tempitem.wpn5 = 0;
9126 840 tempitem.wpn6 = 0;
9127 840 tempitem.wpn7 = 0;
9128 840 tempitem.wpn8 = 0;
9129 840 tempitem.wpn9 = 0;
9130 840 tempitem.wpn10 = 0;
9131 840 break;
9132 }
9133 case itype_heartring:
9134 {
9135 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9136 843 tempitem.misc3 = 0;
9137 843 tempitem.misc4 = 0;
9138 843 tempitem.misc5 = 0;
9139 843 tempitem.misc6 = 0;
9140 843 tempitem.misc7 = 0;
9141 843 tempitem.misc8 = 0;
9142 843 tempitem.misc9 = 0;
9143 843 tempitem.misc10 = 0;
9144 843 tempitem.wpn = 0;
9145 843 tempitem.wpn2 = 0;
9146 843 tempitem.wpn3 = 0;
9147 843 tempitem.wpn4 = 0;
9148 843 tempitem.wpn5 = 0;
9149 843 tempitem.wpn6 = 0;
9150 843 tempitem.wpn7 = 0;
9151 843 tempitem.wpn8 = 0;
9152 843 tempitem.wpn9 = 0;
9153 843 tempitem.wpn10 = 0;
9154 843 break;
9155 }
9156 case itype_magicring:
9157 {
9158 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9159 1128 tempitem.misc3 = 0;
9160 1128 tempitem.misc4 = 0;
9161 1128 tempitem.misc5 = 0;
9162 1128 tempitem.misc6 = 0;
9163 1128 tempitem.misc7 = 0;
9164 1128 tempitem.misc8 = 0;
9165 1128 tempitem.misc9 = 0;
9166 1128 tempitem.misc10 = 0;
9167 1128 tempitem.wpn = 0;
9168 1128 tempitem.wpn2 = 0;
9169 1128 tempitem.wpn3 = 0;
9170 1128 tempitem.wpn4 = 0;
9171 1128 tempitem.wpn5 = 0;
9172 1128 tempitem.wpn6 = 0;
9173 1128 tempitem.wpn7 = 0;
9174 1128 tempitem.wpn8 = 0;
9175 1128 tempitem.wpn9 = 0;
9176 1128 tempitem.wpn10 = 0;
9177 1128 break;
9178 }
9179 case itype_spinscroll2:
9180 {
9181 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9182 279 tempitem.misc2 = 0;
9183 279 tempitem.misc3 = 0;
9184 279 tempitem.misc4 = 0;
9185 279 tempitem.misc5 = 0;
9186 279 tempitem.misc6 = 0;
9187 279 tempitem.misc7 = 0;
9188 279 tempitem.misc8 = 0;
9189 279 tempitem.misc9 = 0;
9190 279 tempitem.misc10 = 0;
9191 279 tempitem.wpn = 0;
9192 279 tempitem.wpn2 = 0;
9193 279 tempitem.wpn3 = 0;
9194 279 tempitem.wpn4 = 0;
9195 279 tempitem.wpn5 = 0;
9196 279 tempitem.wpn6 = 0;
9197 279 tempitem.wpn7 = 0;
9198 279 tempitem.wpn8 = 0;
9199 279 tempitem.wpn9 = 0;
9200 279 tempitem.wpn10 = 0;
9201 279 break;
9202 }
9203 case itype_quakescroll2:
9204 {
9205 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9206 279 tempitem.misc3 = 0;
9207 279 tempitem.misc4 = 0;
9208 279 tempitem.misc5 = 0;
9209 279 tempitem.misc6 = 0;
9210 279 tempitem.misc7 = 0;
9211 279 tempitem.misc8 = 0;
9212 279 tempitem.misc9 = 0;
9213 279 tempitem.misc10 = 0;
9214 279 tempitem.wpn = 0;
9215 279 tempitem.wpn2 = 0;
9216 279 tempitem.wpn3 = 0;
9217 279 tempitem.wpn4 = 0;
9218 279 tempitem.wpn5 = 0;
9219 279 tempitem.wpn6 = 0;
9220 279 tempitem.wpn7 = 0;
9221 279 tempitem.wpn8 = 0;
9222 279 tempitem.wpn9 = 0;
9223 279 tempitem.wpn10 = 0;
9224 279 break;
9225 }
9226 case itype_agony:
9227 {
9228 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9229 279 tempitem.misc2 = 0;
9230 279 tempitem.misc3 = 0;
9231 279 tempitem.misc4 = 0;
9232 279 tempitem.misc5 = 0;
9233 279 tempitem.misc6 = 0;
9234 279 tempitem.misc7 = 0;
9235 279 tempitem.misc8 = 0;
9236 279 tempitem.misc9 = 0;
9237 279 tempitem.misc10 = 0;
9238 279 tempitem.wpn = 0;
9239 279 tempitem.wpn2 = 0;
9240 279 tempitem.wpn3 = 0;
9241 279 tempitem.wpn4 = 0;
9242 279 tempitem.wpn5 = 0;
9243 279 tempitem.wpn6 = 0;
9244 279 tempitem.wpn7 = 0;
9245 279 tempitem.wpn8 = 0;
9246 279 tempitem.wpn9 = 0;
9247 279 tempitem.wpn10 = 0;
9248 279 break;
9249 }
9250 case itype_stompboots:
9251 {
9252 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9253 279 tempitem.misc1 = 0;
9254 279 tempitem.misc2 = 0;
9255 279 tempitem.misc3 = 0;
9256 279 tempitem.misc4 = 0;
9257 279 tempitem.misc5 = 0;
9258 279 tempitem.misc6 = 0;
9259 279 tempitem.misc7 = 0;
9260 279 tempitem.misc8 = 0;
9261 279 tempitem.misc9 = 0;
9262 279 tempitem.misc10 = 0;
9263 279 tempitem.wpn = 0;
9264 279 tempitem.wpn2 = 0;
9265 279 tempitem.wpn3 = 0;
9266 279 tempitem.wpn4 = 0;
9267 279 tempitem.wpn5 = 0;
9268 279 tempitem.wpn6 = 0;
9269 279 tempitem.wpn7 = 0;
9270 279 tempitem.wpn8 = 0;
9271 279 tempitem.wpn9 = 0;
9272 279 tempitem.wpn10 = 0;
9273 279 break;
9274 }
9275 case itype_whimsicalring:
9276 {
9277 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9278 279 tempitem.misc2 = 0;
9279 279 tempitem.misc3 = 0;
9280 279 tempitem.misc4 = 0;
9281 279 tempitem.misc5 = 0;
9282 279 tempitem.misc6 = 0;
9283 279 tempitem.misc7 = 0;
9284 279 tempitem.misc8 = 0;
9285 279 tempitem.misc9 = 0;
9286 279 tempitem.misc10 = 0;
9287 279 tempitem.wpn = 0;
9288 279 tempitem.wpn2 = 0;
9289 279 tempitem.wpn3 = 0;
9290 279 tempitem.wpn4 = 0;
9291 279 tempitem.wpn5 = 0;
9292 279 tempitem.wpn6 = 0;
9293 279 tempitem.wpn7 = 0;
9294 279 tempitem.wpn8 = 0;
9295 279 tempitem.wpn9 = 0;
9296 279 tempitem.wpn10 = 0;
9297 279 break;
9298 }
9299 case itype_perilring:
9300 {
9301 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9302 306 tempitem.misc2 = 0;
9303 306 tempitem.misc3 = 0;
9304 306 tempitem.misc4 = 0;
9305 306 tempitem.misc5 = 0;
9306 306 tempitem.misc6 = 0;
9307 306 tempitem.misc7 = 0;
9308 306 tempitem.misc8 = 0;
9309 306 tempitem.misc9 = 0;
9310 306 tempitem.misc10 = 0;
9311 306 tempitem.wpn = 0;
9312 306 tempitem.wpn2 = 0;
9313 306 tempitem.wpn3 = 0;
9314 306 tempitem.wpn4 = 0;
9315 306 tempitem.wpn5 = 0;
9316 306 tempitem.wpn6 = 0;
9317 306 tempitem.wpn7 = 0;
9318 306 tempitem.wpn8 = 0;
9319 306 tempitem.wpn9 = 0;
9320 306 tempitem.wpn10 = 0;
9321 306 break;
9322 }
9323 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9324 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9325 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9326 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9327 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9328 {
9329 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9330 10652 tempitem.misc1 = 0;
9331 10652 tempitem.misc2 = 0;
9332 10652 tempitem.misc3 = 0;
9333 10652 tempitem.misc4 = 0;
9334 10652 tempitem.misc5 = 0;
9335 10652 tempitem.misc6 = 0;
9336 10652 tempitem.misc7 = 0;
9337 10652 tempitem.misc8 = 0;
9338 10652 tempitem.misc9 = 0;
9339 10652 tempitem.misc10 = 0;
9340 10652 tempitem.wpn = 0;
9341 10652 tempitem.wpn2 = 0;
9342 10652 tempitem.wpn3 = 0;
9343 10652 tempitem.wpn4 = 0;
9344 10652 tempitem.wpn5 = 0;
9345 10652 tempitem.wpn6 = 0;
9346 10652 tempitem.wpn7 = 0;
9347 10652 tempitem.wpn8 = 0;
9348 10652 tempitem.wpn9 = 0;
9349 10652 tempitem.wpn10 = 0;
9350 10652 break;
9351 }
9352 }
9353 72192 }
9354 //Port quest rules to items
9355
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version <= 31)
9356 {
9357
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9358 {
9359
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9360 139 else tempitem.flags &= ~ item_flag2;
9361 295 }
9362
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9363 {
9364
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9365 123 else tempitem.flags &= ~ item_flag2;
9366 281 }
9367
9368
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9369 {
9370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9371 844 else tempitem.flags &= ~ item_flag4;
9372 844 }
9373
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9374 {
9375
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9376 279 else tempitem.flags &= ~ item_flag3;
9377 297 }
9378 72192 }
9379
9380 //Port quest rules to items
9381
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version <= 37)
9382 {
9383
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9384 {
9385
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9386 203 else tempitem.flags &= ~ item_flag1;
9387 282 }
9388
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9389 {
9390
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9391 17109 else tempitem.flags &= ~ item_flag5;
9392 17547 }
9393
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9394 {
9395
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9396 288 else tempitem.flags &= ~ item_flag5;
9397 297 }
9398
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9399 {
9400 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9401
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9402 520 else tempitem.flags &= ~ item_flag3;
9403 895 }
9404 72192 }
9405
9406
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 38)
9407 {
9408
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9409 {
9410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9411 1404 else tempitem.flags &= ~item_flag4;
9412
9413
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9414 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9415 1404 }
9416
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9417 {
9418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9419 831 else tempitem.flags &= ~item_flag4;
9420
9421
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9422 435 else tempitem.flags |= item_flag2;
9423 831 }
9424 72192 }
9425
9426
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 39)
9427 {
9428
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9429 {
9430
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9431 1158 else tempitem.flags &= ~item_flag5;
9432 1174 }
9433
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9434 {
9435
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9436 {
9437 162 tempitem.flags &= ~(item_flag3|item_flag4);
9438 162 }
9439 else
9440 {
9441 452 tempitem.flags |= item_flag3;
9442
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9443 333 else tempitem.flags &= ~item_flag4;
9444 }
9445 614 }
9446
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9447 {
9448
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9449 {
9450 84 tempitem.flags |= item_flag3;
9451
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9452 28 else tempitem.flags &= ~item_flag4;
9453 84 }
9454 else
9455 {
9456 474 tempitem.flags &= ~(item_flag3|item_flag4);
9457 }
9458 558 }
9459 72192 }
9460
9461
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 40)
9462 {
9463
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9464 {
9465
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9466 934 else tempitem.flags &= ~item_flag1;
9467 1223 }
9468
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9469 {
9470
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9471 18615 else tempitem.flags &= ~item_flag8;
9472 18723 }
9473
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9474 {
9475
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9476 18048 else tempitem.flags &= ~item_flag7;
9477 18126 }
9478
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9479 {
9480 279 tempitem.flags |= item_flag7;
9481 279 }
9482 72192 }
9483
9484
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 41 )
9485 {
9486
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9487 {
9488
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9489 17311 else tempitem.flags &= ~item_flag9;
9490
9491
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9492 17119 else tempitem.flags &= ~item_flag10;
9493 17547 }
9494 72192 }
9495
9496
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 42 )
9497 {
9498
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9499 {
9500
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9501 279 else tempitem.flags &= ~item_flag3;
9502
9503 297 tempitem.flags &= ~item_flag6;
9504 297 }
9505
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9506 {
9507 282 tempitem.flags &= ~item_flag3;
9508 282 }
9509
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9510 {
9511 279 tempitem.flags |= item_flag3;
9512
9513 279 tempitem.flags &= ~item_flag6;
9514 279 }
9515
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9516 {
9517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9518 17547 else tempitem.flags &= ~item_flag6;
9519 17547 }
9520 72192 }
9521
9522
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 43 )
9523 {
9524
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9525 {
9526
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9527 317 else tempitem.flags &= ~item_flag3;
9528 327 }
9529 72192 }
9530
9531
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 45 )
9532 {
9533
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9534 {
9535 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9536 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9537 282 }
9538 72192 }
9539
9540
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 46 )
9541 {
9542
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9543 {
9544 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9545 279 }
9546 72192 }
9547
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 34 ) //! set the default counter for older quests.
9548 {
9549
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9550 {
9551 116 tempitem.cost_counter[0] = 1;
9552 116 }
9553 else
9554 {
9555
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9556 42496 tempitem.cost_counter[0] = 4;
9557 else
9558 {
9559 29580 tempitem.cost_amount[0] = 0;
9560 29580 tempitem.cost_counter[0] = -1;
9561 }
9562 }
9563 72192 }
9564
9565
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 35 ) //new Lens of Truth flags
9566 {
9567
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9568 {
9569
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9570 {
9571 10 tempitem.flags |= item_flag4;
9572 10 }
9573
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9574 {
9575 166 tempitem.flags |= item_flag1;
9576 166 }
9577
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9578 {
9579 13 tempitem.flags |= item_flag5;
9580 13 }
9581 255 }
9582 72192 }
9583
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9584 {
9585
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9586 {
9587 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9588 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9589 577536 tempitem.sprite_initiald[q] = 0;
9590 577536 }
9591 72192 tempitem.sprite_script = 0;
9592 72192 }
9593
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9594 {
9595 72192 tempitem.pickupflag = 0;
9596 72192 }
9597
9598
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 51 )
9599 {
9600
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9601 {
9602 600 tempitem.misc4 = 50; //Step speed
9603 600 }
9604 72192 }
9605
9606
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 52 )
9607 {
9608
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9609 858 tempitem.flags |= item_flag1; //'Block Front' flag
9610 72192 }
9611
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if(s_version < 53)
9612 {
9613
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9614 {
9615 case itype_arrow:
9616 831 tempitem.cost_counter[1] = crARROWS;
9617 831 tempitem.cost_amount[1] = 1;
9618 831 break;
9619 case itype_bomb:
9620 295 tempitem.cost_counter[1] = crBOMBS;
9621 295 tempitem.cost_amount[1] = 1;
9622 295 break;
9623 case itype_sbomb:
9624 281 tempitem.cost_counter[1] = crSBOMBS;
9625 281 tempitem.cost_amount[1] = 1;
9626 281 break;
9627 default:
9628 70785 tempitem.cost_counter[1] = crNONE;
9629 70785 tempitem.cost_amount[1] = 0;
9630 70785 }
9631 72192 tempitem.magiccosttimer[1] = 0;
9632 72192 }
9633
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if( s_version < 54 )
9634 {
9635
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9636 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9637 75008 }
9638
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if(s_version < 55)
9639 {
9640
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9641 {
9642 case itype_spinscroll:
9643 case itype_quakescroll:
9644 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9645 580 break;
9646 case itype_spinscroll2:
9647 case itype_quakescroll2:
9648 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9649 580 break;
9650 }
9651 75008 }
9652
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if(s_version < 56)
9653 {
9654
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9655 {
9656 case itype_divinefire:
9657
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9658
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9659 290 tempitem.flags |= item_flag11; //Divine Fire
9660 290 break;
9661 case itype_candle:
9662
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9663 626 tempitem.flags &= ~item_flag10; //Magic Fire
9664 626 tempitem.flags &= ~item_flag11; //Divine Fire
9665 626 break;
9666 case itype_book:
9667 306 tempitem.flags |= item_flag9; //Strong Fire
9668 306 tempitem.flags |= item_flag10; //Magic Fire
9669 306 tempitem.flags &= ~item_flag11; //Divine Fire
9670 306 break;
9671 }
9672 75008 }
9673
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 83968 times.
127232 if (s_version < 61)
9674 {
9675
2/2
✓ Branch 0 taken 65566 times.
✓ Branch 1 taken 18402 times.
83968 switch (tempitem.type)
9676 {
9677 case itype_sword:
9678 18402 tempitem.usesound2 = WAV_BEAM;
9679 18402 break;
9680 }
9681 83968 }
9682
9683
9684
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 116244 times.
127232 if(tempitem.level==0) // Always do this
9685 10988 tempitem.level=1;
9686
9687 127232 itemsbuf[i] = tempitem;
9688 127232 }
9689
9690 497 return 0;
9691 498 }
9692
9693 static bool did_init_def_items = false;
9694 254330 void init_def_items()
9695 {
9696
2/2
✓ Branch 0 taken 253947 times.
✓ Branch 1 taken 383 times.
254330 if(did_init_def_items) return;
9697 383 did_init_def_items = true;
9698 383 default_items[3].cost_counter[1] = crBOMBS;
9699 383 default_items[13].cost_counter[1] = crARROWS;
9700 383 default_items[14].cost_counter[1] = crARROWS;
9701 383 default_items[48].cost_counter[1] = crSBOMBS;
9702 383 default_items[57].cost_counter[1] = crARROWS;
9703 254330 }
9704 254330 void reset_itembuf(itemdata *item, int32_t id)
9705 {
9706 254330 init_def_items();
9707
2/2
✓ Branch 0 taken 107011 times.
✓ Branch 1 taken 147319 times.
254330 if(id<iLast)
9708 {
9709 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9710 147319 word tile = item->tile;
9711 147319 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9712 147319 int32_t ltm = item->ltm;
9713
9714 147319 *item = default_items[id];
9715 147319 item->tile = tile;
9716 147319 item->misc_flags = miscs;
9717 147319 item->csets = cset;
9718 147319 item->frames = frames;
9719 147319 item->speed = speed;
9720 147319 item->delay = delay;
9721 147319 item->ltm = ltm;
9722 147319 }
9723 254330 }
9724
9725 104448 void reset_itemname(int32_t id)
9726 {
9727 104448 sprintf(item_string[id],"zz%03d",id);
9728
9729
2/2
✓ Branch 0 taken 46104 times.
✓ Branch 1 taken 58344 times.
104448 if(id < iLast)
9730 58344 strcpy(item_string[id],old_item_string[id]);
9731 104448 }
9732
9733 498 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9734 {
9735
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9736
9737 498 word weapons_to_read=MAXWPNS;
9738 int32_t dummy;
9739 byte padding;
9740 wpndata tempweapon;
9741 498 word s_version=0;
9742
9743
9744
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(Header->zelda_version < 0x186)
9745 {
9746 6 weapons_to_read=64;
9747 6 }
9748
9749
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(Header->zelda_version < 0x185)
9750 {
9751 6 weapons_to_read=32;
9752 6 }
9753
9754
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(Header->zelda_version > 0x192)
9755 {
9756 474 weapons_to_read=0;
9757
9758 //section version info
9759
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
9760 {
9761 return qe_invalid;
9762 }
9763
9764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_WEAPONS)
9765 return qe_version;
9766
9767 474 FFCore.quest_format[vWeaponSprites] = s_version;
9768
9769
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
9770 {
9771 return qe_invalid;
9772 }
9773
9774 //section size
9775
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
9776 {
9777 return qe_invalid;
9778 }
9779
9780 //finally... section data
9781
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&weapons_to_read,f))
9782 {
9783 return qe_invalid;
9784 }
9785
9786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (weapons_to_read > MAXWPNS)
9787 {
9788 return qe_invalid;
9789 }
9790 474 }
9791
9792
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 83 times.
498 if(s_version>2)
9793 {
9794
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i=0; i<weapons_to_read; i++)
9795 {
9796 char tempname[64];
9797
9798
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!pfread(tempname, 64, f))
9799 {
9800 return qe_invalid;
9801 }
9802
9803 106240 weapon_string[i][0] = '\0';
9804 106240 strncat(weapon_string[i], tempname, 64 - 1);
9805 106240 }
9806
9807
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version<4)
9808 {
9809 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9810 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9811 }
9812
9813
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version<5)
9814 {
9815 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9816 }
9817
9818 /*
9819 if (s_version<6)
9820 {
9821 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9822 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9823 }
9824 */
9825 415 }
9826
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9827 {
9828
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9829 20992 reset_weaponname(i);
9830 82 }
9831
9832
2/2
✓ Branch 0 taken 115052 times.
✓ Branch 1 taken 498 times.
115550 for(int32_t i=0; i<weapons_to_read; i++)
9833 {
9834 115052 word oldtile = 0;
9835
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 61292 times.
115052 if (s_version < 8)
9836 {
9837
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9838 return qe_invalid;
9839 61292 }
9840
9841
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.misc,f))
9842 {
9843 return qe_invalid;
9844 }
9845
9846
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.csets,f))
9847 {
9848 return qe_invalid;
9849 }
9850
9851
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.frames,f))
9852 {
9853 return qe_invalid;
9854 }
9855
9856
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.speed,f))
9857 {
9858 return qe_invalid;
9859 }
9860
9861
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.type,f))
9862 {
9863 return qe_invalid;
9864 }
9865
9866
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 55040 times.
115052 if ( s_version >= 7 )
9867 {
9868
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempweapon.script,f))
9869 {
9870 return qe_invalid;
9871 }
9872
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempweapon.tile,f))
9873 {
9874 return qe_invalid;
9875 }
9876 55040 }
9877
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 60012 times.
115052 if ( s_version < 7 )
9878 {
9879 60012 tempweapon.tile = oldtile;
9880 60012 }
9881
9882
2/2
✓ Branch 0 taken 110252 times.
✓ Branch 1 taken 4800 times.
115052 if(Header->zelda_version < 0x193)
9883 {
9884
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9885 {
9886 return qe_invalid;
9887 }
9888 4800 }
9889
9890
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 8812 times.
115052 if(s_version < 6)
9891 {
9892
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9893 {
9894 18 tempweapon.misc |= WF_BEHIND;
9895 18 }
9896 else
9897 8794 tempweapon.misc &= ~WF_BEHIND;
9898 8812 }
9899
9900
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 114796 times.
115052 if (!should_skip)
9901 114796 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9902 115052 }
9903
9904
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (should_skip)
9905 1 return 0;
9906
9907
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(s_version<2)
9908 {
9909 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9910 82 }
9911
9912
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(s_version<5)
9913 {
9914 82 wpnsbuf[iwQuarterHearts].tile=1;
9915 82 wpnsbuf[iwQuarterHearts].csets=1;
9916 82 }
9917
9918
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(Header->zelda_version < 0x176)
9919 {
9920 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9921 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9922 itemsbuf[iMisc1].clear();
9923 itemsbuf[iMisc2].clear();
9924 }
9925
9926
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
502 if((Header->zelda_version < 0x192)||
9927
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 474 times.
479 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9928 {
9929 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9930 18 }
9931
9932
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if((Header->zelda_version < 0x210))
9933 {
9934 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9935 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9936 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9937 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9938 23 }
9939
9940 497 return 0;
9941 498 }
9942
9943 224965 static void guy_update_firesfx(guydata& tempguy)
9944 {
9945 224965 tempguy.firesfx = 0;
9946
2/2
✓ Branch 0 taken 6559 times.
✓ Branch 1 taken 218406 times.
224965 if (tempguy.type == eeWIZZ)
9947 {
9948
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 989 times.
✓ Branch 2 taken 4010 times.
✓ Branch 3 taken 844 times.
✓ Branch 4 taken 716 times.
6559 switch (tempguy.attributes[1])
9949 {
9950 case 0: // normal weapon
9951 4010 tempguy.firesfx = WAV_WAND;
9952 4010 break;
9953 case 1: // 8 shots
9954
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 762 times.
844 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9955 else
9956 {
9957
3/8
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
762 switch (tempguy.weapon)
9958 {
9959 case ewFireTrail:
9960 case ewFlame:
9961 case ewFlame2Trail:
9962 case ewFlame2:
9963 658 tempguy.firesfx = WAV_FIRE;
9964 658 break;
9965 case ewWind:
9966 case ewMagic:
9967 88 tempguy.firesfx = WAV_WAND;
9968 88 break;
9969 case ewIce:
9970 tempguy.firesfx = WAV_ZN1ICE;
9971 break;
9972 case ewRock:
9973 tempguy.firesfx = WAV_ZN1ROCK;
9974 break;
9975 case ewFireball2:
9976 case ewFireball:
9977 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9978 16 break;
9979 case ewBrang:
9980 tempguy.firesfx = WAV_BRANG;
9981 break;
9982 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9983 tempguy.firesfx = WAV_BOMB;
9984 break;
9985 default:
9986 tempguy.firesfx = 0;
9987 break;
9988 }
9989 762 break;
9990 }
9991 case 2: // Summon
9992 1071 tempguy.firesfx = WAV_FIRE;
9993 1071 break;
9994 case 3: // Summon Layer
9995 716 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9996 716 break;
9997 }
9998 6559 }
9999 else
10000 {
10001
6/6
✓ Branch 0 taken 164563 times.
✓ Branch 1 taken 53843 times.
✓ Branch 2 taken 42795 times.
✓ Branch 3 taken 207358 times.
✓ Branch 4 taken 48321 times.
✓ Branch 5 taken 48317 times.
218406 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
10002 {
10003 96638 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
10004 96638 }
10005 else
10006 {
10007
7/8
✓ Branch 0 taken 9824 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 1832 times.
✓ Branch 3 taken 13082 times.
✓ Branch 4 taken 173858 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4042 times.
✓ Branch 7 taken 2314 times.
207358 switch (tempguy.weapon)
10008 {
10009 case ewFireTrail:
10010 case ewFlame:
10011 case ewFlame2Trail:
10012 case ewFlame2:
10013 9824 tempguy.firesfx = WAV_FIRE;
10014 9824 break;
10015 case ewWind:
10016 case ewMagic:
10017 1832 tempguy.firesfx = WAV_WAND;
10018 1832 break;
10019 case ewIce:
10020 tempguy.firesfx = WAV_ZN1ICE;
10021 break;
10022 case ewRock:
10023 4042 tempguy.firesfx = WAV_ZN1ROCK;
10024 4042 break;
10025 case ewFireball2:
10026 case ewFireball:
10027 13082 tempguy.firesfx = WAV_ZN1FIREBALL;
10028 13082 break;
10029 case ewBrang:
10030 2314 tempguy.firesfx = WAV_BRANG;
10031 2314 break;
10032 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
10033 2406 tempguy.firesfx = WAV_BOMB;
10034 2406 break;
10035 default:
10036 173858 tempguy.firesfx = 0;
10037 173858 break;
10038 }
10039 }
10040 }
10041 213921 }
10042
10043 213921 static void guy_update_weaponflags(guydata& tempguy)
10044 {
10045 213921 tempguy.weap_data.unblockable = 0;
10046 213921 tempguy.weap_data.moveflags = move_none;
10047
4/4
✓ Branch 0 taken 207252 times.
✓ Branch 1 taken 6669 times.
✓ Branch 2 taken 3068 times.
✓ Branch 3 taken 204184 times.
213921 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
10048 9737 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
10049 213921 tempguy.weap_data.override_flags = 0;
10050 213921 tempguy.weap_data.hxofs = 0;
10051 213921 tempguy.weap_data.hyofs = 0;
10052 213921 tempguy.weap_data.hxsz = 0;
10053 213921 tempguy.weap_data.hysz = 0;
10054 213921 tempguy.weap_data.hzsz = 0;
10055 213921 tempguy.weap_data.xofs = 0;
10056 213921 tempguy.weap_data.yofs = 0;
10057 213921 tempguy.weap_data.tilew = 0;
10058 213921 tempguy.weap_data.tileh = 0;
10059
5/5
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 171846 times.
✓ Branch 2 taken 18879 times.
✓ Branch 3 taken 13098 times.
✓ Branch 4 taken 7539 times.
213921 switch (tempguy.weapon)
10060 {
10061 case ewFireball: case ewFireball2:
10062 13098 tempguy.weap_data.step = 1.75_zf;
10063 13098 break;
10064 case ewSword: case ewLitBomb: case ewLitSBomb:
10065 case ewRock: case ewMagic: case ewWind:
10066 18879 tempguy.weap_data.step = 3_zf;
10067 18879 break;
10068 case ewArrow:
10069 2559 tempguy.weap_data.step = 2_zf;
10070 2559 break;
10071 case ewFlame: case ewFlame2:
10072 7539 tempguy.weap_data.step = 1_zf;
10073 7539 break;
10074 default:
10075 171846 tempguy.weap_data.step = 0_zf;
10076 171846 break;
10077 }
10078
2/2
✓ Branch 0 taken 1069605 times.
✓ Branch 1 taken 213921 times.
1283526 for (int q = 0; q < WPNSPR_MAX; ++q)
10079 {
10080 1069605 tempguy.weap_data.burnsprs[q] = 0;
10081 1069605 tempguy.weap_data.light_rads[q] = 0;
10082 1069605 }
10083 213921 }
10084
10085 213921 static void guy_update_weaponspecialsfx(guydata& tempguy)
10086 {
10087
3/3
✓ Branch 0 taken 2314 times.
✓ Branch 1 taken 209146 times.
✓ Branch 2 taken 2461 times.
213921 switch (tempguy.weapon)
10088 {
10089 case ewBrang:
10090 2314 tempguy.specialsfx = WAV_BRANG;
10091 2314 break;
10092 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
10093 2461 tempguy.specialsfx = WAV_BOMB;
10094 2461 break;
10095 default:
10096 209146 tempguy.specialsfx = 0;
10097 209146 break;
10098 }
10099 213921 }
10100
10101 497 void init_guys(int32_t guyversion)
10102 {
10103
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<MAXGUYS; i++)
10104 {
10105 254464 guysbuf[i] = default_guys[0];
10106 254464 }
10107
10108
2/2
✓ Branch 0 taken 87969 times.
✓ Branch 1 taken 497 times.
88466 for(int32_t i=0; i<OLDMAXGUYS; i++)
10109 {
10110 87969 guysbuf[i] = default_guys[i];
10111
2/2
✓ Branch 0 taken 86975 times.
✓ Branch 1 taken 994 times.
87969 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
10112 87969 guysbuf[i].spr_death = iwDeath;
10113 87969 guysbuf[i].spr_spawn = iwSpawn;
10114 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
10115
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 73455 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
87969 if(guyversion<=3 && i==ePATRABS)
10116 {
10117 82 guysbuf[i].bosspal=spDIG;
10118 82 guysbuf[i].cset=14;
10119 82 guysbuf[i].attributes[8] = 14;
10120 82 }
10121
10122
2/2
✓ Branch 0 taken 73455 times.
✓ Branch 1 taken 14514 times.
87969 if(guyversion<=3)
10123 {
10124 // Rope/Ghini Flash rules
10125
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
10126 {
10127
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
10128 {
10129 59 guysbuf[i].flags &= ~guy_flashing;
10130 59 }
10131 10443 }
10132
10133
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
10134 {
10135
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
10136 {
10137 72 guysbuf[i].flags &= ~guy_flashing;
10138 72 }
10139 2124 }
10140
10141
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
10142 {
10143
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
10144 {
10145 4 guysbuf[i].flags |= guy_blinking;
10146 4 }
10147
10148
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
10149 {
10150 38 guysbuf[i].flags |= guy_transparent;
10151 38 }
10152 82 }
10153
10154
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
10155 {
10156 164 guysbuf[i].flags |= guy_ignore_kill_all;
10157 164 }
10158 14514 }
10159
10160 // Darknut fix
10161
10/10
✓ Branch 0 taken 87472 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 86975 times.
✓ Branch 3 taken 497 times.
✓ Branch 4 taken 86478 times.
✓ Branch 5 taken 497 times.
✓ Branch 6 taken 85981 times.
✓ Branch 7 taken 497 times.
✓ Branch 8 taken 497 times.
✓ Branch 9 taken 85484 times.
87969 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
10162 {
10163
2/2
✓ Branch 0 taken 2075 times.
✓ Branch 1 taken 410 times.
2485 if(get_qr(qr_NEWENEMYTILES))
10164 {
10165 2075 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10166 2075 guysbuf[i].s_width=guysbuf[i].e_width;
10167 2075 guysbuf[i].s_height=guysbuf[i].e_height;
10168 2075 }
10169 410 else guysbuf[i].s_tile=860;
10170
10171
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2165 times.
2485 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10172 2165 guysbuf[i].flags &= ~guy_bkshield;
10173 else
10174 320 guysbuf[i].flags |= guy_bkshield;
10175 2485 }
10176
10177
4/4
✓ Branch 0 taken 87472 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 87919 times.
✓ Branch 3 taken 50 times.
87969 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10178 {
10179 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10180 50 }
10181
10182 87969 guy_update_firesfx(guysbuf[i]);
10183 87969 guy_update_weaponflags(guysbuf[i]);
10184 87969 guy_update_weaponspecialsfx(guysbuf[i]);
10185 87969 }
10186 497 }
10187
10188 20992 void reset_weaponname(int32_t i)
10189 {
10190
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10191 {
10192 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10193 7216 }
10194 else
10195 13776 sprintf(weapon_string[i],"zz%03d",i);
10196 20992 }
10197
10198 497 void init_item_drop_sets()
10199 {
10200
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10201 {
10202 // item_drop_sets[i] = default_item_drop_sets[0];
10203 127232 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10204 127232 }
10205
10206
2/2
✓ Branch 0 taken 6461 times.
✓ Branch 1 taken 497 times.
6958 for(int32_t i=0; i<isMAX; i++)
10207 {
10208 6461 item_drop_sets[i] = default_item_drop_sets[i];
10209
10210 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10211
2/2
✓ Branch 0 taken 64610 times.
✓ Branch 1 taken 6461 times.
71071 for(int32_t j=0; j<10; ++j)
10212 {
10213 64610 int32_t it = item_drop_sets[i].item[j];
10214
10215
3/4
✓ Branch 0 taken 45448 times.
✓ Branch 1 taken 19162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2934 times.
64610 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10216
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 42514 times.
45448 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10217 {
10218 2934 item_drop_sets[i].chance[j+1]=0;
10219 2934 }
10220
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 59688 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1844 times.
61676 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10221 {
10222 144 item_drop_sets[i].chance[j+1]=0;
10223 144 }
10224
10225 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10226
2/2
✓ Branch 0 taken 64586 times.
✓ Branch 1 taken 24 times.
64610 if(itemsbuf[it].type == itype_misc)
10227 {
10228 // If a non-gameplay item was selected, then item drop was aborted.
10229 // Reflect this by increasing the 'Nothing' chance accordingly.
10230 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10231 24 item_drop_sets[i].chance[j+1]=0;
10232 24 }
10233 64610 }
10234 6461 }
10235 497 }
10236
10237 497 void init_favorites()
10238 {
10239
2/2
✓ Branch 0 taken 626220 times.
✓ Branch 1 taken 497 times.
626717 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10240 {
10241 626220 favorite_combos[i]=-1;
10242 626220 }
10243 497 }
10244
10245 784 int32_t init_combo_classes()
10246 {
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10248
2/2
✓ Branch 0 taken 144256 times.
✓ Branch 1 taken 784 times.
145040 for(int32_t i=0; i<cMAX; i++)
10249 {
10250 144256 combo_class_buf[i] = default_combo_classes[i];
10251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144256 times.
144256 if ( char const* nm = zi->getComboTypeName(i) )
10252 {
10253 144256 size_t len = strlen(nm);
10254
2/2
✓ Branch 0 taken 9232384 times.
✓ Branch 1 taken 144256 times.
9376640 for ( size_t q = 0; q < 64; q++ )
10255 {
10256
2/2
✓ Branch 0 taken 2114448 times.
✓ Branch 1 taken 7117936 times.
9232384 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10257 9232384 }
10258 144256 }
10259 144256 }
10260
10261 784 return 0;
10262 }
10263
10264 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10265 {
10266
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10268
10269
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10270
10271 305 zinit.hero_swim_speed=67; //default
10272 305 setupherotiles(zinit.heroAnimationStyle);
10273 305 setupherodefenses();
10274 305 setupherooffsets();
10275
10276
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10277 {
10278 word tile, tile2;
10279 byte flip, extend, dummy_byte;
10280
10281
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10282 {
10283
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10284 {
10285 return qe_invalid;
10286 }
10287
10288
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10289 {
10290 return qe_invalid;
10291 }
10292
10293
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10294 {
10295 return qe_invalid;
10296 }
10297
10298 800 walkspr[i][spr_tile]=(int32_t)tile;
10299 800 walkspr[i][spr_flip]=(int32_t)flip;
10300 800 walkspr[i][spr_extend]=(int32_t)extend;
10301 800 }
10302
10303
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10304 {
10305
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10306 {
10307 return qe_invalid;
10308 }
10309
10310
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10311 {
10312 return qe_invalid;
10313 }
10314
10315
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10316 {
10317 return qe_invalid;
10318 }
10319
10320 800 stabspr[i][spr_tile]=(int32_t)tile;
10321 800 stabspr[i][spr_flip]=(int32_t)flip;
10322 800 stabspr[i][spr_extend]=(int32_t)extend;
10323 800 }
10324
10325
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10326 {
10327
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10328 {
10329 return qe_invalid;
10330 }
10331
10332
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10333 {
10334 return qe_invalid;
10335 }
10336
10337
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10338 {
10339 return qe_invalid;
10340 }
10341
10342 800 slashspr[i][spr_tile]=(int32_t)tile;
10343 800 slashspr[i][spr_flip]=(int32_t)flip;
10344 800 slashspr[i][spr_extend]=(int32_t)extend;
10345 800 }
10346
10347
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10348 {
10349
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10350 {
10351 return qe_invalid;
10352 }
10353
10354
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10355 {
10356 return qe_invalid;
10357 }
10358
10359
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10360 {
10361 return qe_invalid;
10362 }
10363
10364 800 floatspr[i][spr_tile]=(int32_t)tile;
10365 800 floatspr[i][spr_flip]=(int32_t)flip;
10366 800 floatspr[i][spr_extend]=(int32_t)extend;
10367 800 }
10368
10369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10370 {
10371
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10372 {
10373
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10374 {
10375 return qe_invalid;
10376 }
10377
10378
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10379 {
10380 return qe_invalid;
10381 }
10382
10383
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10384 {
10385 return qe_invalid;
10386 }
10387
10388 800 swimspr[i][spr_tile]=(int32_t)tile;
10389 800 swimspr[i][spr_flip]=(int32_t)flip;
10390 800 swimspr[i][spr_extend]=(int32_t)extend;
10391 800 }
10392 200 }
10393
10394
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10395 {
10396
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10397 {
10398 return qe_invalid;
10399 }
10400
10401
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411 800 divespr[i][spr_tile]=(int32_t)tile;
10412 800 divespr[i][spr_flip]=(int32_t)flip;
10413 800 divespr[i][spr_extend]=(int32_t)extend;
10414 800 }
10415
10416
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10417 {
10418
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10419 {
10420 return qe_invalid;
10421 }
10422
10423
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10424 {
10425 return qe_invalid;
10426 }
10427
10428
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10429 {
10430 return qe_invalid;
10431 }
10432
10433 800 poundspr[i][spr_tile]=(int32_t)tile;
10434 800 poundspr[i][spr_flip]=(int32_t)flip;
10435 800 poundspr[i][spr_extend]=(int32_t)extend;
10436 800 }
10437
10438
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10439 {
10440 return qe_invalid;
10441 }
10442
10443 200 flip=0;
10444
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10446 {
10447
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10448 {
10449 return qe_invalid;
10450 }
10451 200 }
10452
10453
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10454 {
10455 return qe_invalid;
10456 }
10457
10458 200 castingspr[spr_tile]=(int32_t)tile;
10459 200 castingspr[spr_flip]=(int32_t)flip;
10460 200 castingspr[spr_extend]=(int32_t)extend;
10461
10462
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10463 {
10464 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10465
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10466 {
10467
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10468 {
10469
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10470 {
10471 return qe_invalid;
10472 }
10473
10474
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10475 {
10476 return qe_invalid;
10477 }
10478
10479
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10480 {
10481 return qe_invalid;
10482 }
10483
10484 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10485 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10486 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10487 800 }
10488 400 }
10489 200 }
10490 else
10491 {
10492 for(int32_t i=0; i<2; i++)
10493 {
10494 if(!p_igetw(&tile,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499 if(!p_igetw(&tile2,f))
10500 {
10501 return qe_invalid;
10502 }
10503
10504 if(!p_getc(&extend,f))
10505 {
10506 return qe_invalid;
10507 }
10508
10509 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10510 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10511 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10512 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10513 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10514 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10515 }
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10519 {
10520
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10521 {
10522
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10528 {
10529 return qe_invalid;
10530 }
10531
10532
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10533 {
10534 return qe_invalid;
10535 }
10536
10537 800 jumpspr[i][spr_tile]=(int32_t)tile;
10538 800 jumpspr[i][spr_flip]=(int32_t)flip;
10539 800 jumpspr[i][spr_extend]=(int32_t)extend;
10540 800 }
10541 200 }
10542
10543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10544 {
10545
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10546 {
10547
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10548 {
10549 return qe_invalid;
10550 }
10551
10552
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10553 {
10554 return qe_invalid;
10555 }
10556
10557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10558 {
10559 return qe_invalid;
10560 }
10561
10562 800 chargespr[i][spr_tile]=(int32_t)tile;
10563 800 chargespr[i][spr_flip]=(int32_t)flip;
10564 800 chargespr[i][spr_extend]=(int32_t)extend;
10565 800 }
10566 200 }
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10569 {
10570
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10571 {
10572 return qe_invalid;
10573 }
10574
10575 200 zinit.hero_swim_speed=(byte)dummy_byte;
10576 200 }
10577
10578 200 memset(frozenspr, 0, sizeof(frozenspr));
10579 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10580 200 memset(onfirespr, 0, sizeof(onfirespr));
10581 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10582 200 memset(diggingspr, 0, sizeof(diggingspr));
10583 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10584 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10585 200 memset(pushingspr, 0, sizeof(pushingspr));
10586 200 memset(liftingspr, 0, sizeof(liftingspr));
10587 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10588 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10589 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10590 200 memset(fallingspr, 0, sizeof(fallingspr));
10591 200 memset(shockedspr, 0, sizeof(shockedspr));
10592 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10593 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10594 200 memset(readingspr, 0, sizeof(readingspr));
10595 200 memset(slash180spr, 0, sizeof(slash180spr));
10596 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10597 200 memset(dashspr, 0, sizeof(dashspr));
10598 200 memset(bonkspr, 0, sizeof(bonkspr));
10599 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10600 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10601 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10602
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10603 {
10604
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10605 {
10606 2400 drowningspr[q][p] = divespr[q][p];
10607 2400 drowning_lavaspr[q][p] = divespr[q][p];
10608 2400 }
10609 800 }
10610 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10611 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10612 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10613 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10614 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10615 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10616 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10617 200 }
10618
10619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10620 {
10621 305 bool fastswim = zinit.hero_swim_speed > 60;
10622 // '2/3' or '1/2'
10623 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10624 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10625 305 }
10626 305 return 0;
10627 305 }
10628
10629 36550 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10630 {
10631 36550 arr[spr_tile] = tile;
10632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36550 times.
36550 arr[spr_flip] = (flip > 3 ? 0 : flip);
10633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36550 times.
36550 arr[spr_extend] = (ext > 2 ? 0 : ext);
10634 36550 }
10635 //Used to read the player sprites as int32_t, not word.
10636 215 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10637 {
10638 215 zinit.hero_swim_speed=67; //default
10639 215 setupherotiles(zinit.heroAnimationStyle);
10640 215 setupherodefenses();
10641 215 setupherooffsets();
10642
10643 int32_t tile, tile2;
10644 byte flip, extend, dummy_byte;
10645
10646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>=0)
10647 {
10648
10649
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10650 {
10651
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10652 {
10653 return qe_invalid;
10654 }
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10657 {
10658 return qe_invalid;
10659 }
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10662 {
10663 return qe_invalid;
10664 }
10665
10666 860 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10667 860 }
10668
10669
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10670 {
10671
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10672 {
10673 return qe_invalid;
10674 }
10675
10676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10677 {
10678 return qe_invalid;
10679 }
10680
10681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10682 {
10683 return qe_invalid;
10684 }
10685
10686 860 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10687 860 }
10688
10689
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10690 {
10691
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10692 {
10693 return qe_invalid;
10694 }
10695
10696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10697 {
10698 return qe_invalid;
10699 }
10700
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10702 {
10703 return qe_invalid;
10704 }
10705
10706 860 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10707 860 }
10708
10709
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10710 {
10711
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10712 {
10713 return qe_invalid;
10714 }
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10717 {
10718 return qe_invalid;
10719 }
10720
10721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10722 {
10723 return qe_invalid;
10724 }
10725
10726 860 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10727 860 }
10728
10729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>1)
10730 {
10731
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10732 {
10733
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10734 {
10735 return qe_invalid;
10736 }
10737
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10739 {
10740 return qe_invalid;
10741 }
10742
10743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10744 {
10745 return qe_invalid;
10746 }
10747
10748 860 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10749 860 }
10750 215 }
10751
10752
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10753 {
10754
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10755 {
10756 return qe_invalid;
10757 }
10758
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10760 {
10761 return qe_invalid;
10762 }
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10765 {
10766 return qe_invalid;
10767 }
10768
10769 860 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10770 860 }
10771
10772
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10773 {
10774
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10775 {
10776 return qe_invalid;
10777 }
10778
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10780 {
10781 return qe_invalid;
10782 }
10783
10784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10785 {
10786 return qe_invalid;
10787 }
10788
10789 860 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10790 860 }
10791
10792
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tile,f))
10793 {
10794 return qe_invalid;
10795 }
10796
10797 215 flip=0;
10798
10799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>0)
10800 {
10801
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&flip,f))
10802 {
10803 return qe_invalid;
10804 }
10805 215 }
10806
10807
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&extend,f))
10808 {
10809 return qe_invalid;
10810 }
10811
10812 215 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10813
10814
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(v_herosprites>0)
10815 {
10816 215 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10817
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 215 times.
645 for(int32_t i=0; i<2; i++)
10818 {
10819
2/2
✓ Branch 0 taken 1290 times.
✓ Branch 1 taken 430 times.
1720 for(int32_t j=0; j<num_holdsprs; j++)
10820 {
10821
1/2
✓ Branch 0 taken 1290 times.
✗ Branch 1 not taken.
1290 if(!p_igetl(&tile,f))
10822 {
10823 return qe_invalid;
10824 }
10825
10826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(!p_getc(&flip,f))
10827 {
10828 return qe_invalid;
10829 }
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(!p_getc(&extend,f))
10832 {
10833 return qe_invalid;
10834 }
10835
10836 1290 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10837 1290 }
10838 430 }
10839 215 }
10840 else
10841 {
10842 for(int32_t i=0; i<2; i++)
10843 {
10844 if(!p_igetl(&tile,f))
10845 {
10846 return qe_invalid;
10847 }
10848
10849 if(!p_igetl(&tile2,f))
10850 {
10851 return qe_invalid;
10852 }
10853
10854 if(!p_getc(&extend,f))
10855 {
10856 return qe_invalid;
10857 }
10858
10859 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10860 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10861 }
10862 }
10863
10864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>2)
10865 {
10866
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10867 {
10868
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10869 {
10870 return qe_invalid;
10871 }
10872
10873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10874 {
10875 return qe_invalid;
10876 }
10877
10878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10879 {
10880 return qe_invalid;
10881 }
10882
10883 860 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10884 860 }
10885 215 }
10886
10887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>3)
10888 {
10889
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10890 {
10891
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10892 {
10893 return qe_invalid;
10894 }
10895
10896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10897 {
10898 return qe_invalid;
10899 }
10900
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10902 {
10903 return qe_invalid;
10904 }
10905
10906 860 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10907 860 }
10908 215 }
10909
10910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>4)
10911 {
10912
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&dummy_byte,f))
10913 {
10914 return qe_invalid;
10915 }
10916
10917 215 zinit.hero_swim_speed=(byte)dummy_byte;
10918 215 }
10919
10920
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(v_herosprites>6)
10921 {
10922
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10923 {
10924
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10925 return qe_invalid;
10926
10927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10928 return qe_invalid;
10929
10930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10931 return qe_invalid;
10932
10933 860 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10934 860 }
10935
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10936 {
10937
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10938 return qe_invalid;
10939
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10941 return qe_invalid;
10942
10943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10944 return qe_invalid;
10945
10946 860 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10947 860 }
10948
10949
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10950 {
10951
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10952 return qe_invalid;
10953
10954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10955 return qe_invalid;
10956
10957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10958 return qe_invalid;
10959
10960 860 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10961 860 }
10962
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10963 {
10964
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10965 return qe_invalid;
10966
10967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10968 return qe_invalid;
10969
10970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10971 return qe_invalid;
10972
10973 860 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10974 860 }
10975
10976
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10977 {
10978
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10979 return qe_invalid;
10980
10981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10982 return qe_invalid;
10983
10984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10985 return qe_invalid;
10986
10987 860 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10988 860 }
10989
10990
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10991 {
10992
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10993 return qe_invalid;
10994
10995
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
10996 return qe_invalid;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10999 return qe_invalid;
11000
11001 860 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11002 860 }
11003
11004
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11005 {
11006
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11007 return qe_invalid;
11008
11009
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11010 return qe_invalid;
11011
11012
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11013 return qe_invalid;
11014
11015 860 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11016 860 }
11017
11018
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11019 {
11020
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11021 return qe_invalid;
11022
11023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11024 return qe_invalid;
11025
11026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11027 return qe_invalid;
11028
11029 860 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11030 860 }
11031
11032
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11033 {
11034
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11035 return qe_invalid;
11036
11037
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11038 return qe_invalid;
11039
11040
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11041 return qe_invalid;
11042
11043 860 byte frames = 0;
11044
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 840 times.
860 if(v_herosprites > 15)
11045 {
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&frames,f))
11047 return qe_invalid;
11048 840 }
11049
11050 860 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11051 860 liftingspr[q][spr_frames] = frames;
11052 860 }
11053
11054
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11055 {
11056
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11057 return qe_invalid;
11058
11059
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11060 return qe_invalid;
11061
11062
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11063 return qe_invalid;
11064
11065 860 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11066 860 }
11067
11068
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11069 {
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&tile,f))
11071 return qe_invalid;
11072
11073
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11074 return qe_invalid;
11075
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11077 return qe_invalid;
11078
11079 860 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11080 860 }
11081
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11082 {
11083
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11084 return qe_invalid;
11085
11086
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11087 return qe_invalid;
11088
11089
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11090 return qe_invalid;
11091
11092 860 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11093 860 }
11094
11095
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11096 {
11097
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11098 return qe_invalid;
11099
11100
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11101 return qe_invalid;
11102
11103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11104 return qe_invalid;
11105
11106 860 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11107 860 }
11108
11109
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11110 {
11111
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11112 return qe_invalid;
11113
11114
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11115 return qe_invalid;
11116
11117
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11118 return qe_invalid;
11119
11120 860 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11121 860 }
11122
11123
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11124 {
11125
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11126 return qe_invalid;
11127
11128
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11129 return qe_invalid;
11130
11131
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11132 return qe_invalid;
11133
11134 860 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11135 860 }
11136
11137
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11138 {
11139
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11140 return qe_invalid;
11141
11142
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11143 return qe_invalid;
11144
11145
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11146 return qe_invalid;
11147
11148 860 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11149 860 }
11150
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11151 {
11152
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11153 return qe_invalid;
11154
11155
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11156 return qe_invalid;
11157
11158
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11159 return qe_invalid;
11160
11161 860 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11162 860 }
11163
11164
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11165 {
11166
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11170 return qe_invalid;
11171
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11173 return qe_invalid;
11174
11175 860 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11176 860 }
11177
11178
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11179 {
11180
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11181 return qe_invalid;
11182
11183
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11184 return qe_invalid;
11185
11186
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11187 return qe_invalid;
11188
11189 860 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11190 860 }
11191
11192
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11193 {
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&tile,f))
11195 return qe_invalid;
11196
11197
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11198 return qe_invalid;
11199
11200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11201 return qe_invalid;
11202
11203 860 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11204 860 }
11205
11206
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11207 {
11208
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11209 return qe_invalid;
11210
11211
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11212 return qe_invalid;
11213
11214
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11215 return qe_invalid;
11216
11217 860 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11218 860 }
11219
11220
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11221 {
11222
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11223 return qe_invalid;
11224
11225
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11226 return qe_invalid;
11227
11228
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11229 return qe_invalid;
11230
11231 860 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11232 860 }
11233
11234
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11235 {
11236
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11237 return qe_invalid;
11238
11239
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11240 return qe_invalid;
11241
11242
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11243 return qe_invalid;
11244
11245 860 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11246 860 }
11247
11248
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 215 times.
860 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11249 {
11250
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_igetl(&tile,f))
11251 return qe_invalid;
11252
11253
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_getc(&flip,f))
11254 return qe_invalid;
11255
11256
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_getc(&extend,f))
11257 return qe_invalid;
11258
11259 645 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11260 645 }
11261 215 }
11262 else
11263 {
11264 memset(frozenspr, 0, sizeof(frozenspr));
11265 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11266 memset(onfirespr, 0, sizeof(onfirespr));
11267 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11268 memset(diggingspr, 0, sizeof(diggingspr));
11269 memset(usingrodspr, 0, sizeof(usingrodspr));
11270 memset(usingcanespr, 0, sizeof(usingcanespr));
11271 memset(pushingspr, 0, sizeof(pushingspr));
11272 memset(liftingspr, 0, sizeof(liftingspr));
11273 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11274 memset(stunnedspr, 0, sizeof(stunnedspr));
11275 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11276 memset(fallingspr, 0, sizeof(fallingspr));
11277 memset(shockedspr, 0, sizeof(shockedspr));
11278 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11279 memset(pullswordspr, 0, sizeof(pullswordspr));
11280 memset(readingspr, 0, sizeof(readingspr));
11281 memset(slash180spr, 0, sizeof(slash180spr));
11282 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11283 memset(dashspr, 0, sizeof(dashspr));
11284 memset(bonkspr, 0, sizeof(bonkspr));
11285 memset(medallionsprs, 0, sizeof(medallionsprs));
11286 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11287 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11288 for(int32_t q = 0; q < 4; ++q)
11289 {
11290 for(int32_t p = 0; p < 3; ++p)
11291 {
11292 drowningspr[q][p] = divespr[q][p];
11293 drowning_lavaspr[q][p] = divespr[q][p];
11294 }
11295 }
11296 }
11297
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 8)
11298 {
11299
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11300 {
11301
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11302 return qe_invalid;
11303
11304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11305 return qe_invalid;
11306
11307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11308 return qe_invalid;
11309
11310 860 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11311 860 }
11312 215 }
11313 else
11314 {
11315 memset(sideswimspr, 0, sizeof(sideswimspr));
11316 }
11317
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 9)
11318 {
11319
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11320 {
11321
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11322 return qe_invalid;
11323
11324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11325 return qe_invalid;
11326
11327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11328 return qe_invalid;
11329
11330 860 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11331 860 }
11332
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11333 {
11334
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11335 return qe_invalid;
11336
11337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11338 return qe_invalid;
11339
11340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11341 return qe_invalid;
11342
11343 860 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11344 860 }
11345
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11346 {
11347
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11348 return qe_invalid;
11349
11350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11351 return qe_invalid;
11352
11353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11354 return qe_invalid;
11355
11356 860 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11357 860 }
11358
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11359 {
11360
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11361 return qe_invalid;
11362
11363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11364 return qe_invalid;
11365
11366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11367 return qe_invalid;
11368
11369 860 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11370 860 }
11371 215 }
11372 else
11373 {
11374 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11375 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11376 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11377 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11378 }
11379
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 10)
11380 {
11381
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11382 {
11383 int32_t hmr;
11384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&hmr,f))
11385 return qe_invalid;
11386
11387 860 hammeroffsets[q] = hmr;
11388 860 }
11389 215 }
11390 else
11391 {
11392 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11393 }
11394
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 11)
11395 {
11396
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 215 times.
860 for(int32_t q = 0; q < 3; ++q)
11397 {
11398
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_igetl(&tile,f))
11399 return qe_invalid;
11400
11401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
645 if(!p_getc(&flip,f))
11402 return qe_invalid;
11403
11404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
645 if(!p_getc(&extend,f))
11405 return qe_invalid;
11406
11407 645 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11408 645 }
11409 215 }
11410 else
11411 {
11412 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11413 }
11414
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 12)
11415 {
11416
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tile,f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&flip,f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&extend,f))
11423 return qe_invalid;
11424 215 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11425
11426 215 }
11427 else
11428 {
11429 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11430 }
11431
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 13)
11432 {
11433
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11434 {
11435
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11436 return qe_invalid;
11437
11438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11439 return qe_invalid;
11440
11441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11442 return qe_invalid;
11443
11444 860 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11445 860 }
11446 215 }
11447 else
11448 {
11449 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11450 }
11451
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 14)
11452 {
11453
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11454 {
11455
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11456 return qe_invalid;
11457
11458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11459 return qe_invalid;
11460
11461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11462 return qe_invalid;
11463
11464 860 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11465 860 }
11466 215 }
11467 else
11468 {
11469 memset(revslashspr, 0, sizeof(revslashspr));
11470 }
11471
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 7)
11472 {
11473 215 int32_t num_defense = wMax;
11474 215 byte def = 0;
11475
11476 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11477 /*if(v_herosprites > [x])
11478 * {
11479 * num_defense = 146 //value of wMax on version 8
11480 * }
11481 */
11482
11483
2/2
✓ Branch 0 taken 31390 times.
✓ Branch 1 taken 215 times.
31605 for (int32_t q = 0; q < num_defense; q++)
11484 {
11485
1/2
✓ Branch 0 taken 31390 times.
✗ Branch 1 not taken.
31390 if (!p_getc(&def, f))
11486 return qe_invalid;
11487
11488 31390 hero_defenses[q] = def;
11489 31390 }
11490 215 }
11491 else
11492 {
11493 int32_t num_defense = wMax;
11494 for (int32_t q = 0; q < num_defense; q++)
11495 {
11496 hero_defenses[q] = 0;
11497 }
11498 }
11499 215 }
11500
11501
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 11 times.
215 if(FFCore.quest_format[vInitData] < 34)
11502 {
11503 11 bool fastswim = zinit.hero_swim_speed > 60;
11504 // '2/3' or '1/2'
11505 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11506 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11507 11 }
11508 215 return 0;
11509 215 }
11510
11511
11512 415 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11513 {
11514 //these are here to bypass compiler warnings about unused arguments
11515 415 Header=Header;
11516
11517 dword dummy;
11518 415 word s_version=0;
11519
11520 //section version info
11521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
11522 {
11523 return qe_invalid;
11524 }
11525
11526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_HEROSPRITES)
11527 return qe_version;
11528
11529 415 FFCore.quest_format[vHeroSprites] = s_version;
11530
11531
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
11532 {
11533 return qe_invalid;
11534 }
11535
11536 //section size
11537
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
11538 {
11539 return qe_invalid;
11540 }
11541
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 6 )
11542 {
11543 215 return readherosprites3(f, s_version);
11544 }
11545 200 else return readherosprites2(f, s_version);
11546 415 }
11547
11548 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11549 {
11550 217 subscreens_active.clear();
11551 217 subscreens_passive.clear();
11552 217 subscreens_overlay.clear();
11553 217 subscreens_map.clear();
11554
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<OLD_MAXCUSTOMSUBSCREENS; i++)
11555 {
11556 subscreen_group g;
11557 27776 memset(&g,0,sizeof(subscreen_group));
11558 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11560 return ret;
11561
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11562
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11563 1117 ZCSubscreen& sub = vec.emplace_back();
11564 1117 sub.load_old(g);
11565 1117 }
11566
11567 217 return 0;
11568 217 }
11569
11570 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11571 {
11572 27776 int32_t numsub=0;
11573 27776 byte temp_ss=0;
11574 subscreen_object temp_sub_stack;
11575 27776 subscreen_object *temp_sub = &temp_sub_stack;
11576
11577 char tempname[64];
11578
11579 // FWIW I never saw anything bigger than 20.
11580 #define MAX_DP1_LEN 1024
11581 char tempdp1[MAX_DP1_LEN];
11582
11583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11584 {
11585 return qe_invalid;
11586 }
11587
11588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11589 {
11590
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11591 {
11592 return qe_invalid;
11593 }
11594 27776 }
11595
11596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11597 {
11598 uint8_t tmp=0;
11599
11600 if(!p_getc(&tmp,f))
11601 {
11602 return qe_invalid;
11603 }
11604
11605 numsub = (int32_t)tmp;
11606 }
11607 else
11608 {
11609 word tmp;
11610
11611
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11612 {
11613 return qe_invalid;
11614 }
11615
11616 27776 numsub = (int32_t)tmp;
11617 }
11618
11619 int32_t j;
11620
11621
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<OLD_MAXSUBSCREENITEMS&&j<numsub); j++)
11622 {
11623 44174 memset(temp_sub,0,sizeof(subscreen_object));
11624
11625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11626 {
11627 case ssoTEXT:
11628 case ssoTEXTBOX:
11629 case ssoCURRENTITEMTEXT:
11630 case ssoCURRENTITEMCLASSTEXT:
11631 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11632
11633 //fall through
11634 default:
11635 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11636 44174 break;
11637 }
11638
11639
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11640 return qe_invalid;
11641
11642
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11643 return qe_invalid;
11644
11645
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11646 {
11647 switch(temp_sub->pos)
11648 {
11649 case 0:
11650 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11651 break;
11652
11653 case 1:
11654 temp_sub->pos = sspUP;
11655 break;
11656
11657 case 2:
11658 temp_sub->pos = sspDOWN;
11659 break;
11660
11661 default:
11662 temp_sub->pos = 0;
11663 }
11664 }
11665
11666
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11667 return qe_invalid;
11668
11669
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11670 return qe_invalid;
11671
11672
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11673 return qe_invalid;
11674
11675
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11676 return qe_invalid;
11677
11678
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11679 return qe_invalid;
11680
11681
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11682 return qe_invalid;
11683
11684
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11685 return qe_invalid;
11686
11687
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11688 return qe_invalid;
11689
11690
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11691 return qe_invalid;
11692
11693
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11694 return qe_invalid;
11695
11696
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11697 return qe_invalid;
11698
11699
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11700 return qe_invalid;
11701
11702
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11703 return qe_invalid;
11704
11705
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11706 return qe_invalid;
11707
11708
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11709 return qe_invalid;
11710
11711
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11712 return qe_invalid;
11713
11714
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11715 return qe_invalid;
11716
11717
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11718 return qe_invalid;
11719
11720
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11721 return qe_invalid;
11722
11723
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11724 return qe_invalid;
11725
11726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11727 {
11728 if(!p_igetl(&(temp_sub->speed),f))
11729 return qe_invalid;
11730
11731 if(!p_igetl(&(temp_sub->delay),f))
11732 return qe_invalid;
11733
11734 if(!p_igetl(&(temp_sub->frame),f))
11735 return qe_invalid;
11736 }
11737 else
11738 {
11739
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11740 return qe_invalid;
11741
11742
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11743 return qe_invalid;
11744
11745
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11746 return qe_invalid;
11747 }
11748
11749 44174 int32_t temp_size=0;
11750
11751 // bool deletets = false;
11752
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11753 {
11754 case ssoTEXT:
11755 case ssoTEXTBOX:
11756 case ssoCURRENTITEMTEXT:
11757 case ssoCURRENTITEMCLASSTEXT:
11758 {
11759 word temptempsize;
11760
11761
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11762 {
11763 return qe_invalid;
11764 }
11765
11766 //temptempsize = temp1 + (temp2 << 8);
11767 3389 temp_size = (int32_t)temptempsize;
11768 3389 uint32_t char_length = temp_size+2;
11769
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11770 {
11771 return qe_invalid;
11772 }
11773 3389 tempdp1[char_length - 1] = '\0';
11774
11775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11776
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11777 return qe_invalid;
11778 3389 break;
11779 }
11780
11781 case ssoLIFEMETER:
11782
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11783 temp_sub->d3 = 1;
11784
11785
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11786 return qe_invalid;
11787
11788 242 break;
11789
11790
11791 case ssoCURRENTITEM:
11792
11793
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11794 {
11795 switch(temp_sub->d1)
11796 {
11797 case ssiBOMB:
11798 temp_sub->d1 = itype_bomb;
11799 break;
11800
11801 case ssiSWORD:
11802 temp_sub->d1 = itype_sword;
11803 break;
11804
11805 case ssiSHIELD:
11806 temp_sub->d1 = itype_shield;
11807 break;
11808
11809 case ssiCANDLE:
11810 temp_sub->d1 = itype_candle;
11811 break;
11812
11813 case ssiLETTER:
11814 temp_sub->d1 = itype_letter;
11815 break;
11816
11817 case ssiPOTION:
11818 temp_sub->d1 = itype_potion;
11819 break;
11820
11821 case ssiLETTERPOTION:
11822 temp_sub->d1 = itype_letterpotion;
11823 break;
11824
11825 case ssiBOW:
11826 temp_sub->d1 = itype_bow;
11827 break;
11828
11829 case ssiARROW:
11830 temp_sub->d1 = itype_arrow;
11831 break;
11832
11833 case ssiBOWANDARROW:
11834 temp_sub->d1 = itype_bowandarrow;
11835 break;
11836
11837 case ssiBAIT:
11838 temp_sub->d1 = itype_bait;
11839 break;
11840
11841 case ssiRING:
11842 temp_sub->d1 = itype_ring;
11843 break;
11844
11845 case ssiBRACELET:
11846 temp_sub->d1 = itype_bracelet;
11847 break;
11848
11849 case ssiMAP:
11850 temp_sub->d1 = itype_map;
11851 break;
11852
11853 case ssiCOMPASS:
11854 temp_sub->d1 = itype_compass;
11855 break;
11856
11857 case ssiBOSSKEY:
11858 temp_sub->d1 = itype_bosskey;
11859 break;
11860
11861 case ssiMAGICKEY:
11862 temp_sub->d1 = itype_magickey;
11863 break;
11864
11865 case ssiBRANG:
11866 temp_sub->d1 = itype_brang;
11867 break;
11868
11869 case ssiWAND:
11870 temp_sub->d1 = itype_wand;
11871 break;
11872
11873 case ssiRAFT:
11874 temp_sub->d1 = itype_raft;
11875 break;
11876
11877 case ssiLADDER:
11878 temp_sub->d1 = itype_ladder;
11879 break;
11880
11881 case ssiWHISTLE:
11882 temp_sub->d1 = itype_whistle;
11883 break;
11884
11885 case ssiBOOK:
11886 temp_sub->d1 = itype_book;
11887 break;
11888
11889 case ssiWALLET:
11890 temp_sub->d1 = itype_wallet;
11891 break;
11892
11893 case ssiSBOMB:
11894 temp_sub->d1 = itype_sbomb;
11895 break;
11896
11897 case ssiHCPIECE:
11898 temp_sub->d1 = itype_heartpiece;
11899 break;
11900
11901 case ssiAMULET:
11902 temp_sub->d1 = itype_amulet;
11903 break;
11904
11905 case ssiFLIPPERS:
11906 temp_sub->d1 = itype_flippers;
11907 break;
11908
11909 case ssiHOOKSHOT:
11910 temp_sub->d1 = itype_hookshot;
11911 break;
11912
11913 case ssiLENS:
11914 temp_sub->d1 = itype_lens;
11915 break;
11916
11917 case ssiHAMMER:
11918 temp_sub->d1 = itype_hammer;
11919 break;
11920
11921 case ssiBOOTS:
11922 temp_sub->d1 = itype_boots;
11923 break;
11924
11925 case ssiDIVINEFIRE:
11926 temp_sub->d1 = itype_divinefire;
11927 break;
11928
11929 case ssiDIVINEESCAPE:
11930 temp_sub->d1 = itype_divineescape;
11931 break;
11932
11933 case ssiDIVINEPROTECTION:
11934 temp_sub->d1 = itype_divineprotection;
11935 break;
11936
11937 case ssiQUIVER:
11938 temp_sub->d1 = itype_quiver;
11939 break;
11940
11941 case ssiBOMBBAG:
11942 temp_sub->d1 = itype_bombbag;
11943 break;
11944
11945 case ssiCBYRNA:
11946 temp_sub->d1 = itype_cbyrna;
11947 break;
11948
11949 case ssiROCS:
11950 temp_sub->d1 = itype_rocs;
11951 break;
11952
11953 case ssiHOVERBOOTS:
11954 temp_sub->d1 = itype_hoverboots;
11955 break;
11956
11957 case ssiSPINSCROLL:
11958 temp_sub->d1 = itype_spinscroll;
11959 break;
11960
11961 case ssiCROSSSCROLL:
11962 temp_sub->d1 = itype_crossscroll;
11963 break;
11964
11965 case ssiQUAKESCROLL:
11966 temp_sub->d1 = itype_quakescroll;
11967 break;
11968
11969 case ssiWHISPRING:
11970 temp_sub->d1 = itype_whispring;
11971 break;
11972
11973 case ssiCHARGERING:
11974 temp_sub->d1 = itype_chargering;
11975 break;
11976
11977 case ssiPERILSCROLL:
11978 temp_sub->d1 = itype_perilscroll;
11979 break;
11980
11981 case ssiWEALTHMEDAL:
11982 temp_sub->d1 = itype_wealthmedal;
11983 break;
11984
11985 case ssiHEARTRING:
11986 temp_sub->d1 = itype_heartring;
11987 break;
11988
11989 case ssiMAGICRING:
11990 temp_sub->d1 = itype_magicring;
11991 break;
11992
11993 case ssiSPINSCROLL2:
11994 temp_sub->d1 = itype_spinscroll2;
11995 break;
11996
11997 case ssiQUAKESCROLL2:
11998 temp_sub->d1 = itype_quakescroll2;
11999 break;
12000
12001 case ssiAGONY:
12002 temp_sub->d1 = itype_agony;
12003 break;
12004
12005 case ssiSTOMPBOOTS:
12006 temp_sub->d1 = itype_stompboots;
12007 break;
12008
12009 case ssiWHIMSICALRING:
12010 temp_sub->d1 = itype_whimsicalring;
12011 break;
12012
12013 case ssiPERILRING:
12014 temp_sub->d1 = itype_perilring;
12015 break;
12016
12017 default:
12018 temp_sub->d1 += itype_custom1 - ssiMAX;
12019 }
12020 }
12021
12022 //fall-through
12023 default:
12024
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
12025 return qe_invalid;
12026
12027 40543 break;
12028 }
12029
12030
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
12031 {
12032
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
12033 {
12034 case ssoMAGICGAUGE:
12035 {
12036
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
12037 1136 temp_sub->d9 = -1; //-1 now represents 'always'
12038 1270 break;
12039 }
12040 case ssoLIFEGAUGE:
12041 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12042 4568 break;
12043 }
12044 35480 }
12045
12046
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
12047 {
12048 case ssoTEXT:
12049 case ssoTEXTBOX:
12050 case ssoCURRENTITEMTEXT:
12051 case ssoCURRENTITEMCLASSTEXT:
12052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
12053
12054 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
12055 3389 g->objects[j].dp1 = new char[temp_size+2];
12056 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
12057 3389 break;
12058
12059 case ssoCOUNTER:
12060
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
12061 {
12062 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12063 temp_sub->d8=0;
12064 }
12065
12066 default:
12067 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
12068 40785 break;
12069 }
12070
12071 44174 g->name[0] = '\0';
12072 44174 strncat(g->name, tempname, 64 - 1);
12073 44174 g->ss_type = temp_ss;
12074 44174 }
12075
12076
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<OLD_MAXSUBSCREENITEMS; j++)
12077 {
12078 //clear all unused object in this subscreen -DD
12079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
12080 {
12081 case ssoTEXT:
12082 case ssoTEXTBOX:
12083 case ssoCURRENTITEMTEXT:
12084 case ssoCURRENTITEMCLASSTEXT:
12085 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
12086
12087 //fall through
12088 default:
12089 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
12090 7066482 break;
12091 }
12092 7066482 }
12093
12094 27776 return 0;
12095 27776 }
12096
12097 415 int32_t readsubscreens(PACKFILE *f)
12098 {
12099 word s_version;
12100 dword dummy;
12101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
12102 return qe_invalid;
12103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_SUBSCREEN)
12104 return qe_version;
12105 415 FFCore.quest_format[vSubscreen] = s_version;
12106
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
12107 return qe_invalid;
12108
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f)) //section size
12109 return qe_invalid;
12110
12111
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version < 8)
12112 217 return read_old_subscreens(f,s_version);
12113
12114 198 subscreens_active.clear();
12115 198 subscreens_passive.clear();
12116 198 subscreens_overlay.clear();
12117 198 subscreens_map.clear();
12118
12119 byte sz;
12120
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12121 return qe_invalid;
12122
2/2
✓ Branch 0 taken 626 times.
✓ Branch 1 taken 198 times.
824 for(byte q = 0; q < sz; ++q)
12123 {
12124 626 ZCSubscreen& tmp = subscreens_active.emplace_back();
12125
1/2
✓ Branch 0 taken 626 times.
✗ Branch 1 not taken.
626 if (auto ret = tmp.read(f, s_version))
12126 return ret;
12127 626 }
12128
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12129 return qe_invalid;
12130
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 198 times.
951 for(byte q = 0; q < sz; ++q)
12131 {
12132 753 ZCSubscreen& tmp = subscreens_passive.emplace_back();
12133
1/2
✓ Branch 0 taken 753 times.
✗ Branch 1 not taken.
753 if (auto ret = tmp.read(f, s_version))
12134 return ret;
12135 753 }
12136
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12137 return qe_invalid;
12138
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 198 times.
208 for(byte q = 0; q < sz; ++q)
12139 {
12140 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
12141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
12142 return ret;
12143 10 }
12144
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 133 times.
198 if (s_version >= 16)
12145 {
12146
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&sz,f))
12147 return qe_invalid;
12148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 for(byte q = 0; q < sz; ++q)
12149 {
12150 ZCSubscreen& tmp = subscreens_map.emplace_back();
12151 if (auto ret = tmp.read(f, s_version))
12152 return ret;
12153 }
12154 133 }
12155 198 return 0;
12156 415 }
12157
12158 void reset_subscreen(subscreen_group *tempss)
12159 {
12160 for(int32_t i=0; i<OLD_MAXSUBSCREENITEMS; ++i)
12161 {
12162 switch(tempss->objects[i].type)
12163 {
12164 case ssoTEXT:
12165 case ssoTEXTBOX:
12166 case ssoCURRENTITEMTEXT:
12167 case ssoCURRENTITEMCLASSTEXT:
12168 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12169
12170 //fall through
12171 default:
12172 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12173 break;
12174 }
12175 }
12176 }
12177
12178 117 void reset_subscreens()
12179 {
12180 117 subscreens_active.clear();
12181 117 subscreens_passive.clear();
12182 117 subscreens_overlay.clear();
12183 117 subscreens_map.clear();
12184 117 }
12185
12186 117 int32_t setupsubscreens()
12187 {
12188 117 reset_subscreens();
12189 //return 0;
12190
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12191 {
12192 234 subscreens_active.emplace_back();
12193 234 subscreens_passive.emplace_back();
12194 234 }
12195 117 int32_t tempsubscreen=subscr_mode;
12196
12197
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12198 tempsubscreen=0;
12199
12200
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12201 {
12202 case ssdtOLD:
12203 case ssdtNEWSUBSCR:
12204 case ssdtREV2:
12205 case ssdtBSZELDA:
12206 case ssdtBSZELDAMODIFIED:
12207 case ssdtBSZELDAENHANCED:
12208 case ssdtBSZELDACOMPLETE:
12209 {
12210 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12211 117 subscreens_active[0].sub_type=sstACTIVE;
12212 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12213 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12214 117 subscreens_active[1].sub_type=sstACTIVE;
12215 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12216 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12217 117 subscreens_passive[0].sub_type=sstPASSIVE;
12218 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12219 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12220 117 subscreens_passive[1].sub_type=sstPASSIVE;
12221 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12222 117 break;
12223 }
12224
12225 case ssdtZ3:
12226 {
12227 subscreens_active[0].load_old(z3_active_a);
12228 subscreens_active[0].sub_type=sstACTIVE;
12229 subscreens_active[1].load_old(z3_active_ab);
12230 subscreens_active[1].sub_type=sstACTIVE;
12231 subscreens_passive[0].load_old(z3_passive_a);
12232 subscreens_passive[0].sub_type=sstPASSIVE;
12233 subscreens_passive[1].load_old(z3_passive_ab);
12234 subscreens_passive[1].sub_type=sstPASSIVE;
12235 break;
12236 }
12237 }
12238 117 subscr_mode = ssdtMAX;
12239 117 return 0;
12240 }
12241
12242 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12243
12244 extern script_data *ffscripts[NUMSCRIPTFFC];
12245 extern script_data *itemscripts[NUMSCRIPTITEM];
12246 extern script_data *guyscripts[NUMSCRIPTGUYS];
12247 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12248 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12249 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12250 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12251 extern script_data *playerscripts[NUMSCRIPTHERO];
12252 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12253 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12254 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12255 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12256 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12257
12258 static std::vector<const script_data*> read_scripts;
12259
12260 442 static script_data fake_script_data(ScriptType::None, 0);
12261
12262 527 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12263 {
12264 int32_t dummy;
12265 527 word s_version=0, zmeta_version=0;
12266 527 byte numscripts=0;
12267 527 numscripts=numscripts; //to avoid unused variables warnings
12268 int32_t ret;
12269 527 read_scripts.clear();
12270 527 zasm_scripts.clear();
12271
12272 //section version info
12273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!p_igetw(&s_version,f))
12274 {
12275 return qe_invalid;
12276 }
12277
12278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (s_version > V_FFSCRIPT)
12279 return qe_version;
12280
12281 527 FFCore.quest_format[vFFScript] = s_version;
12282
12283
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!read_deprecated_section_cversion(f))
12284 {
12285 return qe_invalid;
12286 }
12287
12288
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 215 times.
527 if(s_version >= 18)
12289 {
12290
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetw(&zmeta_version,f))
12291 {
12292 return qe_invalid;
12293 }
12294 215 }
12295
12296 //section size
12297
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!p_igetl(&dummy,f))
12298 {
12299 return qe_invalid;
12300 }
12301
12302
2/2
✓ Branch 0 taken 307 times.
✓ Branch 1 taken 220 times.
527 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12303 527 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12304
12305
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 148 times.
527 if(s_version >= 27)
12306 {
12307 148 ret = read_quest_zasm(f, s_version);
12308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(ret)
12309 return qe_invalid;
12310 148 }
12311
12312 //finally... section data
12313
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 451 times.
212931 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12314 {
12315 212480 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12316
12317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if (ret)
12318 {
12319 return qe_invalid;
12320 }
12321 212480 }
12322
12323 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12324 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12325 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12326 * there was a version bump a week before a change that broke stuff.
12327 */
12328
7/8
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 215 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 215 times.
451 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12329 {
12330 666 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12331 666 }
12332
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version < 19)
12333 {
12334 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12335 200 }
12336
12337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 1)
12338 {
12339
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12340 {
12341 106240 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12342
12343
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12344 {
12345 return qe_invalid;
12346 }
12347 106240 }
12348
12349
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12350 {
12351 106240 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12352
12353
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12354 {
12355 return qe_invalid;
12356 }
12357 106240 }
12358
12359
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12360 {
12361 106240 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12362
12363
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12364 {
12365 return qe_invalid;
12366 }
12367 106240 }
12368
12369
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12370 {
12371 106240 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12372
12373
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12374 {
12375 return qe_invalid;
12376 }
12377 106240 }
12378
12379
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version > 16)
12380 {
12381
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 215 times.
1935 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12382 {
12383 1720 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12384
12385
1/2
✓ Branch 0 taken 1720 times.
✗ Branch 1 not taken.
1720 if (ret)
12386 {
12387 return qe_invalid;
12388 }
12389 1720 }
12390 215 }
12391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12392 {
12393 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12394 {
12395 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12396
12397 if (ret)
12398 {
12399 return qe_invalid;
12400 }
12401 }
12402
12403 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12404 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12405
12406 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12407 }
12408
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12409 {
12410
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12411 {
12412 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12413
12414
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12415 {
12416 return qe_invalid;
12417 }
12418 800 }
12419
12420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12421
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12422
12423
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12424
12425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12426
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12427
12428
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12429
12430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12431
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12432
12433
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12434
12435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12436
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12437
12438
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12439 200 }
12440 else
12441 {
12442 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12443 {
12444 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12445
12446 if (ret)
12447 {
12448 return qe_invalid;
12449 }
12450 }
12451
12452 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12453 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12454
12455 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12456
12457 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12458 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12459
12460 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12461
12462 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12463 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12464
12465 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12466
12467 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12468 delete globalscripts[GLOBAL_SCRIPT_F6];
12469
12470 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12471
12472 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12473 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12474
12475 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12476 }
12477
12478
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version > 10) //expanded the number of Hero scripts to 5.
12479 {
12480
2/2
✓ Branch 0 taken 1075 times.
✓ Branch 1 taken 215 times.
1290 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12481 {
12482 1075 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12483
12484
1/2
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
1075 if (ret)
12485 {
12486 return qe_invalid;
12487 }
12488 1075 }
12489 215 }
12490 else
12491 {
12492
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12493 {
12494 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12495
12496
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12497 {
12498 return qe_invalid;
12499 }
12500 600 }
12501
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12502
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12503
12504
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12505
12506
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12508
12509
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12510 }
12511
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
415 if(s_version > 8 && s_version < 10)
12512 {
12513
12514 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12515 {
12516 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12517
12518 if (ret)
12519 {
12520 return qe_invalid;
12521 }
12522 }
12523 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12524 {
12525 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12526
12527 if (ret)
12528 {
12529 return qe_invalid;
12530 }
12531 }
12532
12533 }
12534
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >= 10)
12535 {
12536
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12537 {
12538 55040 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12539
12540
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12541 {
12542 return qe_invalid;
12543 }
12544 55040 }
12545
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12546 {
12547 55040 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12548
12549
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12550 {
12551 return qe_invalid;
12552 }
12553 55040 }
12554
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12555 {
12556 55040 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12557
12558
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12559 {
12560 return qe_invalid;
12561 }
12562 55040 }
12563
12564 215 }
12565
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >=12)
12566 {
12567
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12568 {
12569 55040 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12570
12571
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12572 {
12573 return qe_invalid;
12574 }
12575 55040 }
12576 215 }
12577
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >=15)
12578 {
12579
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 215 times.
110295 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12580 {
12581 110080 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12582
12583
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if (ret)
12584 {
12585 return qe_invalid;
12586 }
12587 110080 }
12588 215 }
12589
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >19)
12590 {
12591 215 word numgenscripts = NUMSCRIPTSGENERIC;
12592
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetw(&numgenscripts,f))
12593 {
12594 return qe_invalid;
12595 }
12596
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 215 times.
110295 for(int32_t i = 0; i < numgenscripts; i++)
12597 {
12598 110080 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12599
12600
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if (ret)
12601 {
12602 return qe_invalid;
12603 }
12604 110080 }
12605 215 }
12606
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version >21)
12607 {
12608 198 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12609
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&numsubscripts,f))
12610 {
12611 return qe_invalid;
12612 }
12613
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < numsubscripts; i++)
12614 {
12615 50688 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12616
12617
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12618 {
12619 return qe_invalid;
12620 }
12621 50688 }
12622 198 }
12623 415 }
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 2)
12626 {
12627 int32_t bufsize;
12628 415 p_igetl(&bufsize, f);
12629
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
415 if (bufsize < 0 || bufsize > 1024*1024*10)
12630 {
12631 // God help anyone storing more than 10MB of code in the script buffer.
12632 return qe_invalid;
12633 }
12634 415 char * buf = new char[bufsize+1];
12635 415 pfread(buf, bufsize, f);
12636 415 buf[bufsize]=0;
12637
12638
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 zScript = string(buf);
12639
12640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 delete[] buf;
12641 word numffcbindings;
12642 415 p_igetw(&numffcbindings, f);
12643
12644
2/2
✓ Branch 0 taken 11855 times.
✓ Branch 1 taken 415 times.
12270 for(int32_t i=0; i<numffcbindings; i++)
12645 {
12646 word id;
12647 11855 p_igetw(&id, f);
12648 11855 p_igetl(&bufsize, f);
12649
2/4
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11855 times.
11855 if (bufsize < 0 || bufsize > 1024)
12650 return qe_invalid;
12651 11855 buf = new char[bufsize+1];
12652 11855 pfread(buf, bufsize, f);
12653 11855 buf[bufsize]=0;
12654
12655 //fix for buggy older saved quests -DD
12656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11855 times.
11855 if(id < NUMSCRIPTFFC-1)
12657 11855 ffcmap[id].scriptname = buf;
12658
12659
1/2
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
11855 delete[] buf;
12660 11855 }
12661
12662 word numglobalbindings;
12663 415 p_igetw(&numglobalbindings, f);
12664
12665
2/2
✓ Branch 0 taken 1672 times.
✓ Branch 1 taken 415 times.
2087 for(int32_t i=0; i<numglobalbindings; i++)
12666 {
12667 word id;
12668 1672 p_igetw(&id, f);
12669 1672 p_igetl(&bufsize, f);
12670
2/4
✓ Branch 0 taken 1672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1672 times.
✗ Branch 3 not taken.
1672 if (bufsize < 0 || bufsize > 1024)
12671 return qe_invalid;
12672 1672 buf = new char[bufsize+1];
12673 1672 pfread(buf, bufsize, f);
12674 1672 buf[bufsize]=0;
12675
12676 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12677 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12678 // Ignore these. -DD
12679
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1126 times.
1672 if (id < NUMSCRIPTGLOBAL)
12680 {
12681 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12682
1/2
✓ Branch 0 taken 1126 times.
✗ Branch 1 not taken.
1126 if(strcmp(buf,"~Continue") == 0)
12683 {
12684 globalmap[id].scriptname = "";
12685
12686 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12687 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12688 }
12689 else
12690 {
12691 1126 globalmap[id].scriptname = buf;
12692 }
12693 1126 }
12694
12695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1672 times.
1672 delete[] buf;
12696 1672 }
12697
12698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 3)
12699 {
12700 word numitembindings;
12701 415 p_igetw(&numitembindings, f);
12702
12703
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 415 times.
1806 for(int32_t i=0; i<numitembindings; i++)
12704 {
12705 word id;
12706 1391 p_igetw(&id, f);
12707 1391 p_igetl(&bufsize, f);
12708
2/4
✓ Branch 0 taken 1391 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1391 times.
1391 if (bufsize < 0 || bufsize > 1024)
12709 return qe_invalid;
12710 1391 buf = new char[bufsize+1];
12711 1391 pfread(buf, bufsize, f);
12712 1391 buf[bufsize]=0;
12713
12714 //fix this too
12715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1391 times.
1391 if(id <NUMSCRIPTITEM-1)
12716 1391 itemmap[id].scriptname = buf;
12717
12718
1/2
✓ Branch 0 taken 1391 times.
✗ Branch 1 not taken.
1391 delete[] buf;
12719 1391 }
12720 415 }
12721 //(v9+)
12722
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 8)
12723 {
12724 //npc scripts
12725 word numnpcbindings;
12726 215 p_igetw(&numnpcbindings, f);
12727
12728
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 215 times.
407 for(int32_t i=0; i<numnpcbindings; i++)
12729 {
12730 word id;
12731 192 p_igetw(&id, f);
12732 192 p_igetl(&bufsize, f);
12733
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if (bufsize < 0 || bufsize > 1024)
12734 return qe_invalid;
12735 192 buf = new char[bufsize+1];
12736 192 pfread(buf, bufsize, f);
12737 192 buf[bufsize]=0;
12738
12739 //fix this too
12740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(id <NUMSCRIPTGUYS-1)
12741 192 npcmap[id].scriptname = buf;
12742
12743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 delete[] buf;
12744 192 }
12745 //lweapon
12746 word numlwpnbindings;
12747 215 p_igetw(&numlwpnbindings, f);
12748
12749
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 215 times.
648 for(int32_t i=0; i<numlwpnbindings; i++)
12750 {
12751 word id;
12752 433 p_igetw(&id, f);
12753 433 p_igetl(&bufsize, f);
12754
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
433 if (bufsize < 0 || bufsize > 1024)
12755 return qe_invalid;
12756 433 buf = new char[bufsize+1];
12757 433 pfread(buf, bufsize, f);
12758 433 buf[bufsize]=0;
12759
12760 //fix this too
12761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(id <NUMSCRIPTWEAPONS-1)
12762 433 lwpnmap[id].scriptname = buf;
12763
12764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 delete[] buf;
12765 433 }
12766 //eweapon
12767 word numewpnbindings;
12768 215 p_igetw(&numewpnbindings, f);
12769
12770
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 215 times.
652 for(int32_t i=0; i<numewpnbindings; i++)
12771 {
12772 word id;
12773 437 p_igetw(&id, f);
12774 437 p_igetl(&bufsize, f);
12775
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12776 return qe_invalid;
12777 437 buf = new char[bufsize+1];
12778 437 pfread(buf, bufsize, f);
12779 437 buf[bufsize]=0;
12780
12781 //fix this too
12782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(id <NUMSCRIPTWEAPONS-1)
12783 437 ewpnmap[id].scriptname = buf;
12784
12785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12786 437 }
12787 //hero
12788 word numherobindings;
12789 215 p_igetw(&numherobindings, f);
12790
12791
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 215 times.
258 for(int32_t i=0; i<numherobindings; i++)
12792 {
12793 word id;
12794 43 p_igetw(&id, f);
12795 43 p_igetl(&bufsize, f);
12796
2/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 if (bufsize < 0 || bufsize > 1024)
12797 return qe_invalid;
12798 43 buf = new char[bufsize+1];
12799 43 pfread(buf, bufsize, f);
12800 43 buf[bufsize]=0;
12801
12802 //fix this too
12803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(id <NUMSCRIPTHERO-1)
12804 43 playermap[id].scriptname = buf;
12805
12806
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 delete[] buf;
12807 43 }
12808 //dmaps
12809 word numdmapbindings;
12810 215 p_igetw(&numdmapbindings, f);
12811
12812
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 215 times.
776 for(int32_t i=0; i<numdmapbindings; i++)
12813 {
12814 word id;
12815 561 p_igetw(&id, f);
12816 561 p_igetl(&bufsize, f);
12817
2/4
✓ Branch 0 taken 561 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 561 times.
561 if (bufsize < 0 || bufsize > 1024)
12818 return qe_invalid;
12819 561 buf = new char[bufsize+1];
12820 561 pfread(buf, bufsize, f);
12821 561 buf[bufsize]=0;
12822
12823 //fix this too
12824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 if(id <NUMSCRIPTSDMAP-1)
12825 561 dmapmap[id].scriptname = buf;
12826
12827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 delete[] buf;
12828 561 }
12829 //screen
12830 word numscreenbindings;
12831 215 p_igetw(&numscreenbindings, f);
12832
12833
2/2
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 215 times.
660 for(int32_t i=0; i<numscreenbindings; i++)
12834 {
12835 word id;
12836 445 p_igetw(&id, f);
12837 445 p_igetl(&bufsize, f);
12838
2/4
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 445 times.
✗ Branch 3 not taken.
445 if (bufsize < 0 || bufsize > 1024)
12839 return qe_invalid;
12840 445 buf = new char[bufsize+1];
12841 445 pfread(buf, bufsize, f);
12842 445 buf[bufsize]=0;
12843
12844 //fix this too
12845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 if(id <NUMSCRIPTSDMAP-1)
12846 445 screenmap[id].scriptname = buf;
12847
12848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 delete[] buf;
12849 445 }
12850 215 }
12851
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 11)
12852 {
12853 word numspritebindings;
12854 215 p_igetw(&numspritebindings, f);
12855
12856
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 215 times.
286 for(int32_t i=0; i<numspritebindings; i++)
12857 {
12858 word id;
12859 71 p_igetw(&id, f);
12860 71 p_igetl(&bufsize, f);
12861
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
71 if (bufsize < 0 || bufsize > 1024)
12862 return qe_invalid;
12863 71 buf = new char[bufsize+1];
12864 71 pfread(buf, bufsize, f);
12865 71 buf[bufsize]=0;
12866
12867 //fix this too
12868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(id <NUMSCRIPTSDMAP-1)
12869 71 itemspritemap[id].scriptname = buf;
12870
12871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 delete[] buf;
12872 71 }
12873 215 }
12874
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >= 15)
12875 {
12876 word numcombobindings;
12877 215 p_igetw(&numcombobindings, f);
12878
12879
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 215 times.
432 for(int32_t i=0; i<numcombobindings; i++)
12880 {
12881 word id;
12882 217 p_igetw(&id, f);
12883 217 p_igetl(&bufsize, f);
12884
2/4
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
217 if (bufsize < 0 || bufsize > 1024)
12885 return qe_invalid;
12886 217 buf = new char[bufsize+1];
12887 217 pfread(buf, bufsize, f);
12888 217 buf[bufsize]=0;
12889
12890 //fix this too
12891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(id <NUMSCRIPTSCOMBODATA-1)
12892 217 comboscriptmap[id].scriptname = buf;
12893
12894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 delete[] buf;
12895 217 }
12896 215 }
12897
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 19)
12898 {
12899 word numgenericbindings;
12900 215 p_igetw(&numgenericbindings, f);
12901
12902
2/2
✓ Branch 0 taken 2624 times.
✓ Branch 1 taken 215 times.
2839 for(int32_t i=0; i<numgenericbindings; i++)
12903 {
12904 word id;
12905 2624 p_igetw(&id, f);
12906 2624 p_igetl(&bufsize, f);
12907
2/4
✓ Branch 0 taken 2624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2624 times.
✗ Branch 3 not taken.
2624 if (bufsize < 0 || bufsize > 1024)
12908 return qe_invalid;
12909 2624 buf = new char[bufsize+1];
12910 2624 pfread(buf, bufsize, f);
12911 2624 buf[bufsize]=0;
12912
12913 //fix this too
12914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(id <NUMSCRIPTSGENERIC-1)
12915 2624 genericmap[id].scriptname = buf;
12916
12917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 delete[] buf;
12918 2624 }
12919 215 }
12920
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version > 21)
12921 {
12922 word numsubscreenbindings;
12923 198 p_igetw(&numsubscreenbindings, f);
12924
12925
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 198 times.
216 for(int32_t i=0; i<numsubscreenbindings; i++)
12926 {
12927 word id;
12928 18 p_igetw(&id, f);
12929 18 p_igetl(&bufsize, f);
12930
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if (bufsize < 0 || bufsize > 1024)
12931 return qe_invalid;
12932 18 buf = new char[bufsize+1];
12933 18 pfread(buf, bufsize, f);
12934 18 buf[bufsize]=0;
12935
12936 //fix this too
12937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTSSUBSCREEN-1)
12938 18 subscreenmap[id].scriptname = buf;
12939
12940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
12941 18 }
12942 198 }
12943 415 }
12944
12945 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12946 // This is only updated when the scripts have been recompiled.
12947 // They should all match each other, but there may have been bugs causing this field
12948 // to not always be set so take the largest one.
12949 415 std::optional<word> zscript_version;
12950
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if (s_version >= 16)
12951 {
12952
2/2
✓ Branch 0 taken 9975 times.
✓ Branch 1 taken 215 times.
10190 for (auto script : read_scripts)
12953 {
12954 // Scripts with "0" were saved in a version prior to this field being set.
12955 // See https://discord.com/channels/876899628556091432/1368485306394738718
12956
2/2
✓ Branch 0 taken 9882 times.
✓ Branch 1 taken 93 times.
9975 word ffscript_v = script->meta.ffscript_v == 0 ? 16 : script->meta.ffscript_v;
12957
2/2
✓ Branch 0 taken 9779 times.
✓ Branch 1 taken 196 times.
9975 if (!zscript_version.has_value())
12958 196 zscript_version = ffscript_v;
12959
1/2
✓ Branch 0 taken 9779 times.
✗ Branch 1 not taken.
9779 else if (ffscript_v > zscript_version.value())
12960 zscript_version = ffscript_v;
12961 }
12962
12963
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
215 if (!zscript_version.has_value())
12964 19 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12965 215 }
12966 415 setZScriptVersion(zscript_version.value_or(s_version));
12967 415 read_scripts.clear();
12968
12969 415 return 0;
12970 415 }
12971
12972 void(*reset_scripts_hook)();
12973
12974 497 void reset_scripts()
12975 {
12976 // We can't modify the script data while jit threads are possibly compiling them.
12977
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 486 times.
497 if (reset_scripts_hook)
12978 486 reset_scripts_hook();
12979
12980
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12981 {
12982
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12983 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12984 254464 }
12985
12986
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12987 {
12988
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (ffscripts[i])
12989 254464 ffscripts[i]->disable();
12990 else
12991 ffscripts[i] = new script_data(ScriptType::FFC, i);
12992 254464 }
12993
12994
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12995 {
12996
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (itemscripts[i])
12997 127232 itemscripts[i]->disable();
12998 else
12999 itemscripts[i] = new script_data(ScriptType::Item, i);
13000 127232 }
13001
13002
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13003 {
13004
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (guyscripts[i])
13005 127232 guyscripts[i]->disable();
13006 else
13007 guyscripts[i] = new script_data(ScriptType::NPC, i);
13008 127232 }
13009
13010
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13011 {
13012
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (screenscripts[i])
13013 127232 screenscripts[i]->disable();
13014 else
13015 screenscripts[i] = new script_data(ScriptType::Screen, i);
13016 127232 }
13017
13018
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 497 times.
4473 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13019 {
13020
1/2
✓ Branch 0 taken 3976 times.
✗ Branch 1 not taken.
3976 if (globalscripts[i])
13021 3976 globalscripts[i]->disable();
13022 else
13023 globalscripts[i] = new script_data(ScriptType::Global, i);
13024 3976 }
13025
13026
2/2
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 497 times.
2982 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
13027 {
13028
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if (playerscripts[i])
13029 2485 playerscripts[i]->disable();
13030 else
13031 playerscripts[i] = new script_data(ScriptType::Hero, i);
13032 2485 }
13033
13034
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13035 {
13036
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (lwpnscripts[i])
13037 127232 lwpnscripts[i]->disable();
13038 else
13039 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
13040 127232 }
13041
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13042 {
13043
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (ewpnscripts[i])
13044 127232 ewpnscripts[i]->disable();
13045 else
13046 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
13047 127232 }
13048
13049
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13050 {
13051
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (dmapscripts[i])
13052 127232 dmapscripts[i]->disable();
13053 else
13054 dmapscripts[i] = new script_data(ScriptType::DMap, i);
13055 127232 }
13056
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13057 {
13058
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (itemspritescripts[i])
13059 127232 itemspritescripts[i]->disable();
13060 else
13061 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
13062 127232 }
13063
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13064 {
13065
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (comboscripts[i])
13066 254464 comboscripts[i]->disable();
13067 else
13068 comboscripts[i] = new script_data(ScriptType::Combo, i);
13069 254464 }
13070
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 127232 times.
127729 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
13071 {
13072
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (subscreenscripts[i])
13073 127232 subscreenscripts[i]->disable();
13074 else
13075 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
13076 127232 }
13077 497 }
13078
13079 // 3.0+ calls this.
13080 148 int32_t read_quest_zasm(PACKFILE *f, word s_version)
13081 {
13082 int32_t num_commands;
13083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&num_commands,f))
13084 return qe_invalid;
13085 #ifdef ZC_FUZZ
13086 const int32_t command_limit = 300000;
13087 #else
13088 148 const int32_t command_limit = 25000000;
13089 #endif
13090
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
148 if (num_commands < 0 || num_commands > command_limit)
13091 return qe_invalid;
13092
13093 148 std::vector<ffscript> zasm;
13094
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 zasm.reserve(num_commands);
13095
2/2
✓ Branch 0 taken 6105333 times.
✓ Branch 1 taken 148 times.
6105481 for(int32_t j=0; j<num_commands; j++)
13096 {
13097
1/2
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
6105333 ffscript temp_script;
13098
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetw(&(temp_script.command),f))
13099 return qe_invalid;
13100
13101
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetl(&(temp_script.arg1),f))
13102 return qe_invalid;
13103
13104
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetl(&(temp_script.arg2),f))
13105 return qe_invalid;
13106
13107
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetl(&(temp_script.arg3),f))
13108 return qe_invalid;
13109
13110 6105333 uint32_t sz = 0;
13111
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetl(&sz,f))
13112 return qe_invalid;
13113
2/2
✓ Branch 0 taken 50033 times.
✓ Branch 1 taken 6055300 times.
6105333 if(sz) //string found
13114 {
13115
1/2
✓ Branch 0 taken 50033 times.
✗ Branch 1 not taken.
50033 temp_script.strptr = new std::string();
13116 char dummy;
13117
2/2
✓ Branch 0 taken 976061 times.
✓ Branch 1 taken 50033 times.
1026094 for(size_t q = 0; q < sz; ++q)
13118 {
13119
2/4
✓ Branch 0 taken 976061 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 976061 times.
✗ Branch 3 not taken.
976061 if(!p_getc(&dummy,f))
13120 return qe_invalid;
13121
1/2
✓ Branch 0 taken 976061 times.
✗ Branch 1 not taken.
976061 temp_script.strptr->push_back(dummy);
13122 976061 }
13123 50033 }
13124
2/4
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6105333 times.
✗ Branch 3 not taken.
6105333 if(!p_igetl(&sz,f))
13125 return qe_invalid;
13126
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 6096538 times.
6105333 if(sz) //vector found
13127 {
13128
1/2
✓ Branch 0 taken 8795 times.
✗ Branch 1 not taken.
8795 temp_script.vecptr = new std::vector<int32_t>();
13129 int32_t dummy;
13130
2/2
✓ Branch 0 taken 55395 times.
✓ Branch 1 taken 8795 times.
64190 for(size_t q = 0; q < sz; ++q)
13131 {
13132
2/4
✓ Branch 0 taken 55395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55395 times.
✗ Branch 3 not taken.
55395 if(!p_igetl(&dummy,f))
13133 return qe_invalid;
13134
1/2
✓ Branch 0 taken 55395 times.
✗ Branch 1 not taken.
55395 temp_script.vecptr->push_back(dummy);
13135 55395 }
13136 8795 }
13137
1/2
✓ Branch 0 taken 6105333 times.
✗ Branch 1 not taken.
6105333 zasm.emplace_back(std::move(temp_script));
13138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6105333 times.
6105333 }
13139
13140
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 assert(zasm_scripts.empty());
13141 148 zasm_script_id id = zasm_scripts.size();
13142
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
148 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
13143
13144 148 return 0;
13145 148 }
13146
13147 1132643 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13148 {
13149 ASSERT(script);
13150
2/2
✓ Branch 0 taken 562399 times.
✓ Branch 1 taken 570244 times.
1132643 if(s_version < 27)
13151 562399 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
13152
13153 char exists;
13154
1/2
✓ Branch 0 taken 570244 times.
✗ Branch 1 not taken.
570244 if (!p_getc(&exists, f))
13155 return qe_invalid;
13156
2/2
✓ Branch 0 taken 6840 times.
✓ Branch 1 taken 563404 times.
570244 if (!exists)
13157 {
13158 563404 script->disable();
13159 563404 return 0;
13160 }
13161
13162 //Read meta
13163 {
13164 6840 zasm_meta temp_meta;
13165
13166
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.zasm_v),f))
13167 return qe_invalid;
13168
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.meta_v),f))
13169 return qe_invalid;
13170
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.ffscript_v),f))
13171 return qe_invalid;
13172
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_getc(&(temp_meta.script_type),f))
13173 return qe_invalid;
13174
13175
2/2
✓ Branch 0 taken 54720 times.
✓ Branch 1 taken 6840 times.
61560 for(int32_t q = 0; q < 8; ++q)
13176 {
13177
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getcstr(&temp_meta.run_idens[q],f))
13178 return qe_invalid;
13179 54720 }
13180
13181
2/2
✓ Branch 0 taken 6840 times.
✓ Branch 1 taken 54720 times.
61560 for(int32_t q = 0; q < 8; ++q)
13182
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getc(&(temp_meta.run_types[q]),f))
13183 return qe_invalid;
13184
13185
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_getc(&(temp_meta.flags),f))
13186 return qe_invalid;
13187
13188
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.compiler_v1),f))
13189 return qe_invalid;
13190
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.compiler_v2),f))
13191 return qe_invalid;
13192
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.compiler_v3),f))
13193 return qe_invalid;
13194
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_igetw(&(temp_meta.compiler_v4),f))
13195 return qe_invalid;
13196
13197
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_getcstr(&temp_meta.script_name,f))
13198 return qe_invalid;
13199
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
✗ Branch 3 not taken.
6840 if(!p_getcstr(&temp_meta.author,f))
13200 return qe_invalid;
13201 6840 auto num_meta_attrib = 10;
13202
2/2
✓ Branch 0 taken 68400 times.
✓ Branch 1 taken 6840 times.
75240 for(auto q = 0; q < num_meta_attrib; ++q)
13203 {
13204
2/4
✓ Branch 0 taken 68400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68400 times.
✗ Branch 3 not taken.
68400 if(!p_getcstr(&temp_meta.attributes[q],f))
13205 return qe_invalid;
13206
2/4
✓ Branch 0 taken 68400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68400 times.
✗ Branch 3 not taken.
68400 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13207 return qe_invalid;
13208 68400 }
13209
2/2
✓ Branch 0 taken 54720 times.
✓ Branch 1 taken 6840 times.
61560 for(auto q = 0; q < 8; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getcstr(&temp_meta.attribytes[q],f))
13212 return qe_invalid;
13213
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13214 return qe_invalid;
13215 54720 }
13216
2/2
✓ Branch 0 taken 54720 times.
✓ Branch 1 taken 6840 times.
61560 for(auto q = 0; q < 8; ++q)
13217 {
13218
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13219 return qe_invalid;
13220
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13221 return qe_invalid;
13222 54720 }
13223
2/2
✓ Branch 0 taken 109440 times.
✓ Branch 1 taken 6840 times.
116280 for(auto q = 0; q < 16; ++q)
13224 {
13225
2/4
✓ Branch 0 taken 109440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109440 times.
✗ Branch 3 not taken.
109440 if(!p_getcstr(&temp_meta.usrflags[q],f))
13226 return qe_invalid;
13227
2/4
✓ Branch 0 taken 109440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109440 times.
✗ Branch 3 not taken.
109440 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13228 return qe_invalid;
13229 109440 }
13230
2/2
✓ Branch 0 taken 54720 times.
✓ Branch 1 taken 6840 times.
61560 for(auto q = 0; q < 8; ++q)
13231 {
13232
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getcstr(&temp_meta.initd[q],f))
13233 return qe_invalid;
13234
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getwstr(&temp_meta.initd_help[q],f))
13235 return qe_invalid;
13236 54720 }
13237
2/2
✓ Branch 0 taken 6840 times.
✓ Branch 1 taken 54720 times.
61560 for(auto q = 0; q < 8; ++q)
13238 {
13239
2/4
✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54720 times.
✗ Branch 3 not taken.
54720 if(!p_getc(&temp_meta.initd_type[q],f))
13240 return qe_invalid;
13241 54720 }
13242
13243
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 script->meta = temp_meta;
13244
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
6840 }
13245
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if(!p_igetl(&script->pc, f))
13246 return qe_invalid;
13247
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if(!p_igetl(&script->end_pc, f))
13248 return qe_invalid;
13249
13250
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if (script == &fake_script_data)
13251 return 0;
13252
13253
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 assert(zasm_scripts.size() == 1);
13254 6840 auto& zs = zasm_scripts[0];
13255 6840 script->zasm_script = zs;
13256
13257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6840 times.
6840 if (script->valid())
13258 {
13259 6840 zs->script_datas.push_back(script);
13260 6840 read_scripts.push_back(script);
13261 6840 }
13262
13263 6840 return 0;
13264 1132643 }
13265
13266 562399 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13267 {
13268 562399 char b33[34] = {0};
13269 562399 b33[33] = 0;
13270 562399 int32_t num_commands=1000;
13271
13272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562399 times.
562399 if(s_version>=2)
13273 {
13274
1/2
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
562399 if(!p_igetl(&num_commands,f))
13275 {
13276 return qe_invalid;
13277 }
13278 562399 }
13279
13280 #ifdef ZC_FUZZ
13281 const int32_t command_limit = 300000;
13282 #else
13283 562399 const int32_t command_limit = 10000000;
13284 #endif
13285
2/4
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 562399 times.
562399 if (num_commands < 0 || num_commands > command_limit)
13286 {
13287 return qe_invalid;
13288 }
13289
13290 562399 std::vector<ffscript> zasm;
13291
1/2
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
562399 zasm.reserve(num_commands);
13292
13293
2/2
✓ Branch 0 taken 253799 times.
✓ Branch 1 taken 308600 times.
562399 if(s_version >= 16)
13294 {
13295
1/2
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
253799 zasm_meta temp_meta;
13296
13297
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.zasm_v),f))
13298 {
13299 return qe_invalid;
13300 }
13301
13302
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.meta_v),f))
13303 {
13304 return qe_invalid;
13305 }
13306
13307
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.ffscript_v),f))
13308 {
13309 return qe_invalid;
13310 }
13311
13312
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_getc(&(temp_meta.script_type),f))
13313 {
13314 return qe_invalid;
13315 }
13316
13317
2/2
✓ Branch 0 taken 2030392 times.
✓ Branch 1 taken 253799 times.
2284191 for(int32_t q = 0; q < 8; ++q)
13318 {
13319
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1886512 times.
2030392 if(zmeta_version < 3)
13320 {
13321
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13322 {
13323
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13324 {
13325 return qe_invalid;
13326 }
13327 4748040 }
13328
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13329 143880 }
13330 else
13331 {
13332
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getcstr(&temp_meta.run_idens[q],f))
13333 {
13334 return qe_invalid;
13335 }
13336 }
13337 2030392 }
13338
13339
2/2
✓ Branch 0 taken 253799 times.
✓ Branch 1 taken 2030392 times.
2284191 for(int32_t q = 0; q < 8; ++q)
13340 {
13341
2/4
✓ Branch 0 taken 2030392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2030392 times.
✗ Branch 3 not taken.
2030392 if(!p_getc(&(temp_meta.run_types[q]),f))
13342 {
13343 return qe_invalid;
13344 }
13345 2030392 }
13346
13347
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_getc(&(temp_meta.flags),f))
13348 {
13349 return qe_invalid;
13350 }
13351
13352
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.compiler_v1),f))
13353 {
13354 return qe_invalid;
13355 }
13356
13357
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.compiler_v2),f))
13358 {
13359 return qe_invalid;
13360 }
13361
13362
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.compiler_v3),f))
13363 {
13364 return qe_invalid;
13365 }
13366
13367
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if(!p_igetw(&(temp_meta.compiler_v4),f))
13368 {
13369 return qe_invalid;
13370 }
13371
13372
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 235814 times.
253799 if(zmeta_version == 2)
13373 {
13374
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13375 {
13376
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13377 {
13378 return qe_invalid;
13379 }
13380 593505 }
13381
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13382
13383
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13384 {
13385
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13386 {
13387 return qe_invalid;
13388 }
13389 593505 }
13390
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13391 17985 }
13392
1/2
✓ Branch 0 taken 235814 times.
✗ Branch 1 not taken.
235814 else if(zmeta_version > 2)
13393 {
13394
2/4
✓ Branch 0 taken 235814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235814 times.
✗ Branch 3 not taken.
235814 if(!p_getcstr(&temp_meta.script_name,f))
13395 return qe_invalid;
13396
2/4
✓ Branch 0 taken 235814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235814 times.
✗ Branch 3 not taken.
235814 if(!p_getcstr(&temp_meta.author,f))
13397 return qe_invalid;
13398 235814 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13399
2/2
✓ Branch 0 taken 2358140 times.
✓ Branch 1 taken 235814 times.
2593954 for(auto q = 0; q < num_meta_attrib; ++q)
13400 {
13401
2/4
✓ Branch 0 taken 2358140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2358140 times.
✗ Branch 3 not taken.
2358140 if(!p_getcstr(&temp_meta.attributes[q],f))
13402 return qe_invalid;
13403
2/4
✓ Branch 0 taken 2358140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2358140 times.
✗ Branch 3 not taken.
2358140 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13404 return qe_invalid;
13405 2358140 }
13406
2/2
✓ Branch 0 taken 1886512 times.
✓ Branch 1 taken 235814 times.
2122326 for(auto q = 0; q < 8; ++q)
13407 {
13408
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getcstr(&temp_meta.attribytes[q],f))
13409 return qe_invalid;
13410
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13411 return qe_invalid;
13412 1886512 }
13413
2/2
✓ Branch 0 taken 1886512 times.
✓ Branch 1 taken 235814 times.
2122326 for(auto q = 0; q < 8; ++q)
13414 {
13415
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13416 return qe_invalid;
13417
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13418 return qe_invalid;
13419 1886512 }
13420
2/2
✓ Branch 0 taken 3773024 times.
✓ Branch 1 taken 235814 times.
4008838 for(auto q = 0; q < 16; ++q)
13421 {
13422
2/4
✓ Branch 0 taken 3773024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3773024 times.
✗ Branch 3 not taken.
3773024 if(!p_getcstr(&temp_meta.usrflags[q],f))
13423 return qe_invalid;
13424
2/4
✓ Branch 0 taken 3773024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3773024 times.
✗ Branch 3 not taken.
3773024 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13425 return qe_invalid;
13426 3773024 }
13427 235814 }
13428
2/2
✓ Branch 0 taken 235814 times.
✓ Branch 1 taken 17985 times.
253799 if(zmeta_version > 3)
13429 {
13430
2/2
✓ Branch 0 taken 1886512 times.
✓ Branch 1 taken 235814 times.
2122326 for(auto q = 0; q < 8; ++q)
13431 {
13432
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getcstr(&temp_meta.initd[q],f))
13433 return qe_invalid;
13434
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getwstr(&temp_meta.initd_help[q],f))
13435 return qe_invalid;
13436 1886512 }
13437
2/2
✓ Branch 0 taken 1886512 times.
✓ Branch 1 taken 235814 times.
2122326 for(auto q = 0; q < 8; ++q)
13438 {
13439
2/4
✓ Branch 0 taken 1886512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886512 times.
✗ Branch 3 not taken.
1886512 if(!p_getc(&temp_meta.initd_type[q],f))
13440 return qe_invalid;
13441 1886512 }
13442 235814 }
13443 else
13444 {
13445
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13446 {
13447
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13448 143880 }
13449 }
13450
13451
1/2
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
253799 script->meta = temp_meta;
13452
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 253799 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
562399 } else script->meta = {};
13453
13454
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106043960 times.
106118634 for(int32_t j=0; j<num_commands; j++)
13455 {
13456
1/2
✓ Branch 0 taken 106043960 times.
✗ Branch 1 not taken.
106043960 auto& sc = zasm.emplace_back();
13457
2/4
✓ Branch 0 taken 106043960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106043960 times.
✗ Branch 3 not taken.
106043960 if(!p_igetw(&sc.command,f))
13458 {
13459 return qe_invalid;
13460 }
13461
13462
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 487725 times.
106043960 if(sc.command == 0xFFFF)
13463 487725 break;
13464 else
13465 {
13466
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13467 {
13468 return qe_invalid;
13469 }
13470
13471
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13472 {
13473 return qe_invalid;
13474 }
13475
13476
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13477
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13478 return qe_invalid;
13479
13480
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13481 {
13482 8222037 uint32_t sz = 0;
13483
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13484 {
13485 return qe_invalid;
13486 }
13487
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13488 {
13489
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13490 char dummy;
13491
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13492 {
13493
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13494 {
13495 return qe_invalid;
13496 }
13497
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13498 1165008 }
13499 19400 }
13500
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13501 {
13502 return qe_invalid;
13503 }
13504
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13505 {
13506
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13507 int32_t dummy;
13508
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13509 {
13510
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13511 {
13512 return qe_invalid;
13513 }
13514
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13515 11526 }
13516 933 }
13517 8222037 }
13518 }
13519 105556235 }
13520
13521
2/2
✓ Branch 0 taken 494047 times.
✓ Branch 1 taken 68352 times.
562399 if (script == &fake_script_data)
13522 68352 return 0;
13523
13524 // If the first command is unknown, invalidate the whole thing.
13525 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13526
5/6
✓ Branch 0 taken 424749 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 412772 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 412772 times.
494047 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13527 {
13528 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13529 zasm.clear();
13530 }
13531
13532 494047 zasm_script_id id = zasm_scripts.size();
13533
3/6
✓ Branch 0 taken 494047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494047 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494047 times.
✗ Branch 5 not taken.
494047 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13534 494047 script->zasm_script = zs;
13535 494047 script->pc = 0;
13536 494047 script->end_pc = zs->size;
13537
3/4
✓ Branch 0 taken 494047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 482070 times.
494047 if (script->valid())
13538 {
13539
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13540
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13541 11977 }
13542
13543 494047 return 0;
13544 562399 }
13545
13546 extern SAMPLE customsfxdata[WAV_COUNT];
13547 extern uint8_t customsfxflag[WAV_COUNT>>3];
13548 extern int32_t sfxdat;
13549 extern DATAFILE *sfxdata;
13550 const char *old_sfx_string[Z35] =
13551 {
13552 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13553 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13554 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13555 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13556 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13557 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13558 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13559 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13560 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13561 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13562 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13563 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13564 };
13565 char *sfx_string[WAV_COUNT];
13566
13567 415 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13568 {
13569 //these are here to bypass compiler warnings about unused arguments
13570 415 Header=Header;
13571
13572 int32_t dummy;
13573 415 word s_version=0;
13574 //int32_t ret;
13575 415 SAMPLE temp_sample = {};
13576 415 temp_sample.loop_start=0;
13577 415 temp_sample.loop_end=0;
13578 415 temp_sample.param=0;
13579
13580 //section version info
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
13582 {
13583 return qe_invalid;
13584 }
13585
13586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_SFX)
13587 return qe_version;
13588
13589 415 FFCore.quest_format[vSFX] = s_version;
13590
13591
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
13592 {
13593 return qe_invalid;
13594 }
13595
13596 //section size
13597
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
13598 {
13599 return qe_invalid;
13600 }
13601
13602 /* HIGHLY UNORTHODOX UPDATING THING, by L
13603 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13604 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13605 * changing from 1 to 2.
13606 */
13607
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 2)
13608 set_qr(qr_GOTOLESSNOTEQUAL,1);
13609
13610 /* End highly unorthodox updating thing */
13611
13612 415 int32_t wavcount = WAV_COUNT;
13613
13614
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 6)
13615 wavcount = 128;
13616
13617 uint8_t tempflag[WAV_COUNT>>3];
13618
13619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version < 4)
13620 {
13621 memset(tempflag, 0xFF, WAV_COUNT>>3);
13622 }
13623 else
13624 {
13625
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 6)
13626 memset(tempflag, 0, WAV_COUNT>>3);
13627
13628
2/2
✓ Branch 0 taken 13280 times.
✓ Branch 1 taken 415 times.
13695 for(int32_t i=0; i<(wavcount>>3); i++)
13629 {
13630 13280 p_getc(&tempflag[i], f);
13631 13280 }
13632
13633 }
13634
13635
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version>4)
13636 {
13637
2/2
✓ Branch 0 taken 105825 times.
✓ Branch 1 taken 415 times.
106240 for(int32_t i=1; i<WAV_COUNT; i++)
13638 {
13639 105825 sprintf(sfx_string[i],"s%03d",i);
13640
13641
2/2
✓ Branch 0 taken 80925 times.
✓ Branch 1 taken 24900 times.
105825 if((i<Z35))
13642 24900 strcpy(sfx_string[i], old_sfx_string[i-1]);
13643
13644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105825 times.
105825 if(i>=wavcount)
13645 continue;
13646
2/2
✓ Branch 0 taken 23150 times.
✓ Branch 1 taken 82675 times.
105825 if(get_bit(tempflag, i-1))
13647 {
13648 char tempname[36];
13649
13650
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!pfread(tempname, 36, f))
13651 {
13652 return qe_invalid;
13653 }
13654
13655 23150 sfx_string[i][0] = '\0';
13656 23150 strncat(sfx_string[i], tempname, 36 - 1);
13657 23150 }
13658 else
13659 {
13660 82675 sprintf(sfx_string[i],"s%03d",i);
13661
13662
2/2
✓ Branch 0 taken 72985 times.
✓ Branch 1 taken 9690 times.
82675 if(i<Z35)
13663 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13664 82675 sfx_string[i][35] = 0; //Force NULL Termination
13665 }
13666 105825 }
13667 415 }
13668 else
13669 {
13670 for(int32_t i=1; i<WAV_COUNT; i++)
13671 {
13672 sprintf(sfx_string[i],"s%03d",i);
13673
13674 if(i<Z35)
13675 strcpy(sfx_string[i], old_sfx_string[i-1]);
13676 }
13677 }
13678
13679 //finally... section data
13680
2/2
✓ Branch 0 taken 105825 times.
✓ Branch 1 taken 415 times.
106240 for(int32_t i=1; i<wavcount; i++)
13681 {
13682
2/2
✓ Branch 0 taken 23150 times.
✓ Branch 1 taken 82675 times.
105825 if(get_bit(tempflag, i-1))
13683 {
13684
13685
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13686 {
13687 return qe_invalid;
13688 }
13689
13690 23150 (temp_sample.bits) = dummy;
13691
13692
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13693 {
13694 return qe_invalid;
13695 }
13696
13697 23150 (temp_sample.stereo) = dummy;
13698
13699
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13700 {
13701 return qe_invalid;
13702 }
13703
13704 23150 (temp_sample.freq) = dummy;
13705
13706
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13707 {
13708 return qe_invalid;
13709 }
13710
13711 23150 (temp_sample.priority) = dummy;
13712
13713
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.len),f))
13714 {
13715 return qe_invalid;
13716 }
13717
13718
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.loop_start),f))
13719 {
13720 return qe_invalid;
13721 }
13722
13723
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.loop_end),f))
13724 {
13725 return qe_invalid;
13726 }
13727
13728
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.param),f))
13729 {
13730 return qe_invalid;
13731 }
13732
13733 23150 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13734 #ifdef ZC_FUZZ
13735 const int32_t sfx_limit = 100000;
13736 if (len < 0 || len > sfx_limit)
13737 {
13738 return qe_invalid;
13739 }
13740 #endif
13741 23150 temp_sample.data = calloc(len,1);
13742
13743
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(s_version < 3)
13744 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13745
13746 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23150 times.
23150 if(s_version < 2)
13748 {
13749 if(!pfread(temp_sample.data, len,f))
13750 {
13751 return qe_invalid;
13752 }
13753 }
13754 else
13755 {
13756 //re-endianfy the data
13757 23150 int32_t wordstoread = len / sizeof(word);
13758
13759
2/2
✓ Branch 0 taken 669182603 times.
✓ Branch 1 taken 23150 times.
669205753 for(int32_t j=0; j<wordstoread; j++)
13760 {
13761 word temp;
13762
13763
1/2
✓ Branch 0 taken 669182603 times.
✗ Branch 1 not taken.
669182603 if(!p_igetw(&temp, f))
13764 {
13765 return qe_invalid;
13766 }
13767
13768 669182603 ((word *)temp_sample.data)[j] = temp;
13769 669182603 }
13770 }
13771 23150 }
13772
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 72985 times.
82675 else if(i < Z35)
13773 {
13774 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13775 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13776 9690 set_bit(tempflag, i-1, 1);
13777 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13778 9690 temp_sample.data = calloc(len,1);
13779 9690 memcpy(temp_sample.data, datsamp->data, len);
13780 9690 }
13781 72985 else continue;
13782
13783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32840 times.
32840 if(customsfxdata[i].data!=NULL)
13784 {
13785 // delete [] customsfxdata[i].data;
13786 32840 free(customsfxdata[i].data);
13787 32840 }
13788
13789 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13790 32840 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13791 32840 customsfxdata[i].data = calloc(len2,1);
13792 32840 customsfxdata[i].bits = temp_sample.bits;
13793 32840 customsfxdata[i].stereo = temp_sample.stereo;
13794 32840 customsfxdata[i].freq = temp_sample.freq;
13795 32840 customsfxdata[i].priority = temp_sample.priority;
13796 32840 customsfxdata[i].len = temp_sample.len;
13797 32840 customsfxdata[i].loop_start = temp_sample.loop_start;
13798 32840 customsfxdata[i].loop_end = temp_sample.loop_end;
13799 32840 customsfxdata[i].param = temp_sample.param;
13800 32840 int32_t cpylen = len2;
13801
13802
1/2
✓ Branch 0 taken 32840 times.
✗ Branch 1 not taken.
32840 if(s_version<3)
13803 {
13804 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13805 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13806 }
13807
13808 32840 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13809
13810 32840 free(temp_sample.data);
13811 32840 }
13812
13813 415 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13814
13815 415 sfxdat=0;
13816 415 return 0;
13817 415 }
13818
13819 497 void setupsfx()
13820 {
13821
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=1; i<WAV_COUNT; i++)
13822 {
13823 126735 sprintf(sfx_string[i],"s%03d",i);
13824
13825
2/2
✓ Branch 0 taken 96915 times.
✓ Branch 1 taken 29820 times.
126735 if(i<Z35)
13826 {
13827 29820 strcpy(sfx_string[i], old_sfx_string[i-1]);
13828 29820 }
13829
13830 126735 memset(customsfxflag, 0, WAV_COUNT>>3);
13831
13832 126735 int32_t j=i;
13833
13834
2/2
✓ Branch 0 taken 30317 times.
✓ Branch 1 taken 96418 times.
126735 if(i>Z35)
13835 {
13836 96418 i=Z35;
13837 96418 }
13838
13839 126735 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13840
13841
2/2
✓ Branch 0 taken 97665 times.
✓ Branch 1 taken 29070 times.
126735 if(customsfxdata[j].data!=NULL)
13842 {
13843 // delete [] customsfxdata[j].data;
13844 29070 free(customsfxdata[j].data);
13845 29070 }
13846
13847 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13848 126735 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13849 126735 customsfxdata[j].bits = temp_sample->bits;
13850 126735 customsfxdata[j].stereo = temp_sample->stereo;
13851 126735 customsfxdata[j].freq = temp_sample->freq;
13852 126735 customsfxdata[j].priority = temp_sample->priority;
13853 126735 customsfxdata[j].len = temp_sample->len;
13854 126735 customsfxdata[j].loop_start = temp_sample->loop_start;
13855 126735 customsfxdata[j].loop_end = temp_sample->loop_end;
13856 126735 customsfxdata[j].param = temp_sample->param;
13857 126735 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13858 126735 i=j;
13859 126735 }
13860 497 }
13861
13862 extern char *guy_string[eMAXGUYS];
13863 extern const char *old_guy_string[OLDMAXGUYS];
13864
13865 497 int32_t readguys(PACKFILE *f, zquestheader *Header)
13866 {
13867
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (should_skip) return 0;
13869
13870 dword dummy;
13871 word guy_cversion;
13872 497 word guyversion=0;
13873
13874
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version >= 0x193)
13875 {
13876 //section version info
13877
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&guyversion,f))
13878 {
13879 return qe_invalid;
13880 }
13881
13882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (guyversion > V_GUYS)
13883 return qe_version;
13884
13885 474 FFCore.quest_format[vGuys] = guyversion;
13886
13887 // Note: this is the only instance where "cversion" is ever used.
13888
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&guy_cversion,f))
13889 {
13890 return qe_invalid;
13891 }
13892
13893 //section size
13894
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
13895 {
13896 return qe_invalid;
13897 }
13898 474 }
13899
13900
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(guyversion > 3)
13901 {
13902
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 415 times.
212895 for(int32_t i=0; i<MAXGUYS; i++)
13903 {
13904 char tempname[64];
13905
13906 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13907 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13909 {
13910 memset(tempname, 0, sizeof(char)*64);
13911 sprintf(tempname, "e%03d", i);
13912 strcpy(guy_string[i], tempname);
13913
13914 continue;
13915 }
13916
13917
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!pfread(tempname, 64, f))
13918 {
13919 return qe_invalid;
13920 }
13921
13922 // Don't retain names of uneditable enemy entries!
13923 // for version upgrade to 2.5
13924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(guyversion < 23 && i >= 177)
13925 {
13926 // some of the older builds have names such as 'zz123',
13927 // (this order gets messed up with some eXXX and some zzXXX)
13928 // so let's update to the newer naming convection. -Gleeok
13929 char tmpbuf[64];
13930 memset(tmpbuf, 0, sizeof(char)*64);
13931 sprintf(tmpbuf, "zz%03d", i);
13932
13933 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13934 {
13935 memset(tempname, 0, sizeof(char)*64);
13936 sprintf(tempname, "e%03d", i);
13937 }
13938 }
13939
13940
6/6
✓ Branch 0 taken 73455 times.
✓ Branch 1 taken 139025 times.
✓ Branch 2 taken 69720 times.
✓ Branch 3 taken 3735 times.
✓ Branch 4 taken 61045 times.
✓ Branch 5 taken 8675 times.
212480 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13941 {
13942 203805 guy_string[i][0] = '\0';
13943 203805 strncat(guy_string[i], tempname, 64 - 1);
13944 203805 }
13945 else
13946 {
13947 8675 strcpy(guy_string[i],old_guy_string[i]);
13948 }
13949 212480 }
13950 415 }
13951 else
13952 {
13953
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13954 {
13955 41984 sprintf(guy_string[i],"zz%03d",i);
13956 41984 }
13957
13958
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13959 {
13960 14514 strcpy(guy_string[i],old_guy_string[i]);
13961 14514 }
13962 }
13963
13964
13965 //finally... section data
13966 497 init_guys(guyversion); //using default data for now...
13967
13968 // Goriya guy fix
13969
3/6
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13970 {
13971
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13972 {
13973 60 guysbuf[gGORIYA].tile=130;
13974 60 guysbuf[gGORIYA].e_tile=130;
13975 60 }
13976 82 }
13977
13978
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if(Header->zelda_version < 0x193)
13979 {
13980
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13981 {
13982 5 guysbuf[eDODONGO].cset=14;
13983 5 guysbuf[eDODONGO].bosspal=spDIG;
13984 5 }
13985 23 }
13986 // Not sure when this first changed, but it's necessary for 2.10, at least
13987 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13988 //2.10 Fixes
13989
3/6
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13990 {
13991 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13992 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13993 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13994 82 guysbuf[eCENT1].attributes[2] = 1;
13995 82 guysbuf[eCENT2].attributes[2] = 1;
13996 82 }
13997
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13998 {
13999 497 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
14000 497 }
14001
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(Header->zelda_version <= 0x210)
14002 {
14003 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
14004 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
14005 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
14006 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
14007
14008 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
14009 82 guysbuf[eBATROBE].attributes[3] = 1;
14010 //guysbuf[eSUMMONER].misc4 = 1;
14011 82 guysbuf[eWWIZ].attributes[3] = 1;
14012 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14013 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14014 82 }
14015
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 12 times.
497 if(Header->zelda_version == 0x190)
14016 {
14017 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
14018 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
14019 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
14020 12 }
14021
14022 // The versions here may not be correct
14023 // zelda_version>=0x211 handled at guyversion<24
14024
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 479 times.
497 if(Header->zelda_version <= 0x190)
14025 {
14026 18 guysbuf[eCENT1].attributes[2] = 0;
14027 18 guysbuf[eCENT2].attributes[2] = 0;
14028 18 guysbuf[eMOLDORM].attributes[1] = 0;
14029 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
14030 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
14031 18 }
14032
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 64 times.
479 else if(Header->zelda_version <= 0x210)
14033 {
14034 64 guysbuf[eCENT1].attributes[2] = 1;
14035 64 guysbuf[eCENT2].attributes[2] = 1;
14036 64 guysbuf[eMOLDORM].attributes[1] = 0;
14037 64 }
14038
14039
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
14040 {
14041 82 guysbuf[eKEESE1].attributes[15] = 120;
14042 82 guysbuf[eKEESE2].attributes[15] = 120;
14043 82 guysbuf[eKEESE3].attributes[15] = 120;
14044 82 guysbuf[eKEESETRIB].attributes[15] = 120;
14045 82 guysbuf[eKEESE1].attributes[16] = 16;
14046 82 guysbuf[eKEESE2].attributes[16] = 16;
14047 82 guysbuf[eKEESE3].attributes[16] = 16;
14048 82 guysbuf[eKEESETRIB].attributes[16] = 16;
14049
14050 82 guysbuf[ePEAHAT].attributes[15] = 80;
14051 82 guysbuf[ePEAHAT].attributes[16] = 16;
14052
14053 82 guysbuf[eGHINI2].attributes[15] = 120;
14054 82 guysbuf[eGHINI2].attributes[16] = 10;
14055
14056
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
14057 {
14058 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14059 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14060 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14061 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14062 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14063 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14064 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14065 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14066 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14067 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14068 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14069 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14070 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14071 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14072 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14073 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14074 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14075 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14076 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14077 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14078 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14079 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14080 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14081 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14082 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14083 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14084 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14085 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14086 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14087 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14088 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14089 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14090 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14091 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14092 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14093 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14094 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14095 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14096 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14097 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14098 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14099 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14100 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14101 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14102 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14103 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14104 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14105 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14106 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14107 66 }
14108 82 }
14109
14110
14111
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(guyversion<=2)
14112 {
14113 82 return readherosprites2(f, guyversion==2?0:-1);
14114 }
14115
14116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(guyversion > 3)
14117 {
14118 415 guydata tempguy;
14119
14120
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 415 times.
212895 for(int32_t i=0; i<MAXGUYS; i++)
14121 {
14122
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 23) // May 2012 : 512 max enemies
14123 {
14124 if(i >= OLDBETAMAXGUYS)
14125 {
14126 guysbuf[i].clear();
14127 continue;
14128 }
14129 }
14130
14131 212480 tempguy.clear();
14132
14133 uint32_t flags1;
14134 uint32_t flags2;
14135
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(flags1),f))
14136 {
14137 return qe_invalid;
14138 }
14139
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(flags2),f))
14140 {
14141 return qe_invalid;
14142 }
14143 212480 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
14144
14145
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14146 {
14147
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.tile),f))
14148 {
14149 return qe_invalid;
14150 }
14151 110080 }
14152 else
14153 {
14154
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
14155 {
14156 return qe_invalid;
14157 }
14158 }
14159
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.width),f))
14160 {
14161 return qe_invalid;
14162 }
14163
14164
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.height),f))
14165 {
14166 return qe_invalid;
14167 }
14168
14169
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14170 {
14171
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.s_tile),f))
14172 {
14173 return qe_invalid;
14174 }
14175 110080 }
14176 else
14177 {
14178
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14179 {
14180 return qe_invalid;
14181 }
14182 }
14183
14184
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.s_width),f))
14185 {
14186 return qe_invalid;
14187 }
14188
14189
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.s_height),f))
14190 {
14191 return qe_invalid;
14192 }
14193
14194
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14195 {
14196
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.e_tile),f))
14197 {
14198 return qe_invalid;
14199 }
14200 110080 }
14201 else
14202 {
14203
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14204 {
14205 return qe_invalid;
14206 }
14207 }
14208
14209
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.e_width),f))
14210 {
14211 return qe_invalid;
14212 }
14213
14214
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.e_height),f))
14215 {
14216 return qe_invalid;
14217 }
14218
14219
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.hp),f))
14220 {
14221 return qe_invalid;
14222 }
14223
14224
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.type),f))
14225 {
14226 return qe_invalid;
14227 }
14228
14229
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
212480 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14230 {
14231 if(get_qr(qr_NEWENEMYTILES))
14232 {
14233 tempguy.s_tile=tempguy.e_tile+120;
14234 tempguy.s_width=tempguy.e_width;
14235 tempguy.s_height=tempguy.e_height;
14236 }
14237 else tempguy.s_tile=860;
14238 }
14239
14240
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.cset),f))
14241 {
14242 return qe_invalid;
14243 }
14244
14245
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.anim),f))
14246 {
14247 return qe_invalid;
14248 }
14249
14250
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.e_anim),f))
14251 {
14252 return qe_invalid;
14253 }
14254
14255
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.frate),f))
14256 {
14257 return qe_invalid;
14258 }
14259
14260
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.e_frate),f))
14261 {
14262 return qe_invalid;
14263 }
14264
14265
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 13) // April 2009
14266 {
14267 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14268 {
14269 tempguy.frate *= 2;
14270 tempguy.e_frate *= 2;
14271 }
14272 }
14273
14274
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 14) // May 1 2009
14275 {
14276 if(tempguy.anim==a2FRMSLOW)
14277 {
14278 tempguy.anim=a2FRM;
14279 tempguy.frate *= 2;
14280 }
14281
14282 if(tempguy.e_anim==a2FRMSLOW)
14283 {
14284 tempguy.e_anim=a2FRM;
14285 tempguy.e_frate *= 2;
14286 }
14287
14288 if(tempguy.anim==aFLIPSLOW)
14289 {
14290 tempguy.anim=aFLIP;
14291 tempguy.frate *= 2;
14292 }
14293
14294 if(tempguy.e_anim==aFLIPSLOW)
14295 {
14296 tempguy.e_anim=aFLIP;
14297 tempguy.e_frate *= 2;
14298 }
14299
14300 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14301
14302 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14303
14304 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14305 {
14306 tempguy.anim=a4FRM4DIR;
14307 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14308 }
14309
14310 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14311 {
14312 tempguy.e_anim=a4FRM4DIR;
14313 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14314 }
14315 }
14316
14317
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.dp),f))
14318 {
14319 return qe_invalid;
14320 }
14321
14322 //correction for guy fire
14323
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 6)
14324 {
14325 if(i == gFIRE)
14326 tempguy.dp = 2;
14327 }
14328
14329
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.wdp),f))
14330 {
14331 return qe_invalid;
14332 }
14333
14334
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.weapon),f))
14335 {
14336 return qe_invalid;
14337 }
14338
14339 //correction for bosses using triple, "rising" fireballs
14340
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 5)
14341 {
14342 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14343 i == eGOHMA3 || i == eGOHMA4)
14344 {
14345 if(tempguy.weapon == ewFireball)
14346 tempguy.weapon = ewFireball2;
14347 }
14348 }
14349
14350
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.rate),f))
14351 {
14352 return qe_invalid;
14353 }
14354
14355
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.hrate),f))
14356 {
14357 return qe_invalid;
14358 }
14359
14360
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.step),f))
14361 {
14362 return qe_invalid;
14363 }
14364
14365 // HIGHLY UNORTHODOX UPDATING THING, part 2
14366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(fixpolsvoice && tempguy.type==eePOLSV)
14367 {
14368 tempguy.step /= 2;
14369 }
14370
14371
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.homing),f))
14372 {
14373 return qe_invalid;
14374 }
14375
14376
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.grumble),f))
14377 {
14378 return qe_invalid;
14379 }
14380
14381
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.item_set),f))
14382 {
14383 return qe_invalid;
14384 }
14385
14386
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14387 {
14388
2/2
✓ Branch 0 taken 2124800 times.
✓ Branch 1 taken 212480 times.
2337280 for (int q = 0; q < 10; ++q)
14389 {
14390
1/2
✓ Branch 0 taken 2124800 times.
✗ Branch 1 not taken.
2124800 if (!p_igetl(&(tempguy.attributes[q]), f))
14391 {
14392 return qe_invalid;
14393 }
14394 2124800 }
14395 212480 }
14396 else
14397 {
14398 int16_t tempMisc;
14399
14400 for(int q=0;q<10;q++)
14401 {
14402 if (!p_igetw(&tempMisc, f))
14403 {
14404 return qe_invalid;
14405 }
14406 tempguy.attributes[q] = tempMisc;
14407 }
14408
14409 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14410 {
14411 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14412 tempguy.attributes[4] = 74;
14413 }
14414
14415 }
14416
14417
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.bgsfx),f))
14418 {
14419 return qe_invalid;
14420 }
14421
14422
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.bosspal),f))
14423 {
14424 return qe_invalid;
14425 }
14426
14427
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.extend),f))
14428 {
14429 return qe_invalid;
14430 }
14431
14432 //! Enemy Defences
14433
14434 //If a 2.50 quest, use only the 2.5 defences.
14435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14436 {
14437
2/2
✓ Branch 0 taken 4037120 times.
✓ Branch 1 taken 212480 times.
4249600 for(int32_t j=0; j<edefLAST; j++)
14438 {
14439
1/2
✓ Branch 0 taken 4037120 times.
✗ Branch 1 not taken.
4037120 if(!p_getc(&(tempguy.defense[j]),f))
14440 {
14441 return qe_invalid;
14442 }
14443 4037120 }
14444 //then copy the generic script defence to all the new script defences
14445
14446 212480 }
14447
14448
14449
14450
14451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if(guyversion >= 18)
14452 {
14453
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.hitsfx),f))
14454 {
14455 return qe_invalid;
14456 }
14457
14458
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.deadsfx),f))
14459 {
14460 return qe_invalid;
14461 }
14462 212480 }
14463
14464
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion >= 22)
14465 {
14466
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(tempguy.attributes[10]), f))
14467 {
14468 return qe_invalid;
14469 }
14470
14471
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(tempguy.attributes[11]),f))
14472 {
14473 return qe_invalid;
14474 }
14475 212480 }
14476 else if(guyversion >= 19)
14477 {
14478 int16_t tempMisc;
14479
14480 if(!p_igetw(&tempMisc,f))
14481 {
14482 return qe_invalid;
14483 }
14484
14485 tempguy.attributes[10] = tempMisc;
14486
14487 if(!p_igetw(&tempMisc,f))
14488 {
14489 return qe_invalid;
14490 }
14491
14492 tempguy.attributes[11] = tempMisc;
14493 }
14494
14495 //If a 2.54 or later quest, use all of the defences.
14496
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 24) // Add new guyversion conditional statement
14497 {
14498
2/2
✓ Branch 0 taken 2421760 times.
✓ Branch 1 taken 110080 times.
2531840 for(int32_t j=edefLAST; j<edefLAST255; j++)
14499 {
14500
1/2
✓ Branch 0 taken 2421760 times.
✗ Branch 1 not taken.
2421760 if(!p_getc(&(tempguy.defense[j]),f))
14501 {
14502 return qe_invalid;
14503 }
14504 2421760 }
14505 110080 }
14506
14507
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14508 {
14509
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14510 {
14511 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14512 1024000 }
14513 102400 }
14514
14515 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14516
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 25)
14517 {
14518
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.txsz),f))
14519 {
14520 return qe_invalid;
14521 }
14522
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.tysz),f))
14523 {
14524 return qe_invalid;
14525 }
14526
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hxsz),f))
14527 {
14528 return qe_invalid;
14529 }
14530
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hysz),f))
14531 {
14532 return qe_invalid;
14533 }
14534
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hzsz),f))
14535 {
14536 return qe_invalid;
14537 }
14538 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14539
14540 */
14541 110080 }
14542 //More Enemy Editor vars for 2.60
14543
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 26)
14544 {
14545
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hxofs),f))
14546 {
14547 return qe_invalid;
14548 }
14549
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hyofs),f))
14550 {
14551 return qe_invalid;
14552 }
14553
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.xofs),f))
14554 {
14555 return qe_invalid;
14556 }
14557
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.yofs),f))
14558 {
14559 return qe_invalid;
14560 }
14561
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.zofs),f))
14562 {
14563 return qe_invalid;
14564 }
14565 110080 }
14566
14567
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14568 {
14569 102400 tempguy.wpnsprite = 0;
14570 102400 }
14571
14572
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 27)
14573 {
14574
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.wpnsprite),f))
14575 {
14576 return qe_invalid;
14577 }
14578 110080 }
14579
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14580 {
14581 102400 tempguy.SIZEflags = 0;
14582 102400 }
14583
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 28)
14584 {
14585
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.SIZEflags),f))
14586 {
14587 return qe_invalid;
14588 }
14589
14590 110080 }
14591
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14592 {
14593 102400 tempguy.frozentile = 0;
14594 102400 tempguy.frozencset = 0;
14595 102400 tempguy.frozenclock = 0;
14596
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14597 102400 }
14598
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 30)
14599 {
14600
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozentile),f))
14601 {
14602 return qe_invalid;
14603 }
14604
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozencset),f))
14605 {
14606 return qe_invalid;
14607 }
14608
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozenclock),f))
14609 {
14610 return qe_invalid;
14611 }
14612
2/2
✓ Branch 0 taken 1100800 times.
✓ Branch 1 taken 110080 times.
1210880 for ( int32_t q = 0; q < 10; q++ ) {
14613
1/2
✓ Branch 0 taken 1100800 times.
✗ Branch 1 not taken.
1100800 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14614 {
14615 return qe_invalid;
14616 }
14617 1100800 }
14618
14619 110080 }
14620
14621
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 34)
14622 {
14623
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetw(&(tempguy.firesfx),f))
14624 {
14625 return qe_invalid;
14626 }
14627
2/2
✓ Branch 0 taken 1871360 times.
✓ Branch 1 taken 110080 times.
1981440 for(int q=15;q<32;++q)
14628 {
14629
1/2
✓ Branch 0 taken 1871360 times.
✗ Branch 1 not taken.
1871360 if(!p_igetl(&(tempguy.attributes[q]),f))
14630 {
14631 return qe_invalid;
14632 }
14633 1871360 }
14634
14635
2/2
✓ Branch 0 taken 3522560 times.
✓ Branch 1 taken 110080 times.
3632640 for ( int32_t q = 0; q < 32; q++ ) {
14636
1/2
✓ Branch 0 taken 3522560 times.
✗ Branch 1 not taken.
3522560 if(!p_igetl(&(tempguy.movement[q]),f))
14637 {
14638 return qe_invalid;
14639 }
14640 3522560 }
14641
2/2
✓ Branch 0 taken 3522560 times.
✓ Branch 1 taken 110080 times.
3632640 for ( int32_t q = 0; q < 32; q++ ) {
14642
1/2
✓ Branch 0 taken 3522560 times.
✗ Branch 1 not taken.
3522560 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14643 {
14644 return qe_invalid;
14645 }
14646 3522560 }
14647
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetw(&(tempguy.script),f))
14648 {
14649 return qe_invalid;
14650 }
14651
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
14652 {
14653
1/2
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
880640 if(!p_igetl(&(tempguy.initD[q]),f))
14654 {
14655 return qe_invalid;
14656 }
14657 880640 }
14658
2/2
✓ Branch 0 taken 220160 times.
✓ Branch 1 taken 110080 times.
330240 for ( int32_t q = 0; q < 2; q++ )
14659 {
14660 int32_t temp;
14661
1/2
✓ Branch 0 taken 220160 times.
✗ Branch 1 not taken.
220160 if(!p_igetl(&temp,f))
14662 {
14663 return qe_invalid;
14664 }
14665 220160 }
14666
14667 110080 }
14668
14669
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 37)
14670 {
14671
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.editorflags),f))
14672 {
14673 return qe_invalid;
14674 }
14675 110080 }
14676
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14677
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 38)
14678 {
14679
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[12]),f))
14680 {
14681 return qe_invalid;
14682 }
14683
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[13]),f))
14684 {
14685 return qe_invalid;
14686 }
14687
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[14]),f))
14688 {
14689 return qe_invalid;
14690 }
14691
14692 110080 }
14693
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 38 )
14694 {
14695 102400 tempguy.attributes[12] = 0;
14696 102400 tempguy.attributes[13] = 0;
14697 102400 tempguy.attributes[14] = 0;
14698 102400 }
14699
14700
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if ( guyversion >= 39 )
14701 {
14702
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
14703 {
14704
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; w++ )
14705 {
14706
1/2
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
57241600 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14707 {
14708 return qe_invalid;
14709 }
14710 57241600 }
14711
2/2
✓ Branch 0 taken 667648 times.
✓ Branch 1 taken 212992 times.
880640 if(guyversion < 54)
14712 {
14713 byte dummybyte;
14714
2/2
✓ Branch 0 taken 13844480 times.
✓ Branch 1 taken 212992 times.
14057472 for ( int32_t w = 0; w < 65; w++ )
14715
1/2
✓ Branch 0 taken 13844480 times.
✗ Branch 1 not taken.
13844480 if(!p_getc(&dummybyte,f))
14716 return qe_invalid;
14717 212992 }
14718 880640 }
14719
14720
14721 110080 }
14722
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 39 ) //apply old InitD strings to both
14723 {
14724
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14725 {
14726 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14727 819200 }
14728 102400 }
14729
4/4
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 83456 times.
✓ Branch 3 taken 26624 times.
212480 if ( guyversion >= 40 && guyversion < 54)
14730
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 if(!p_igetw(&(tempguy.weap_data.script),f))
14731 return qe_invalid;
14732
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 40 )
14733 102400 tempguy.weap_data.script = 0;
14734 //eweapon script InitD
14735
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if ( guyversion >= 41 )
14736 {
14737
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 26624 times.
110080 if(guyversion < 54)
14738
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 26624 times.
239616 for ( int32_t q = 0; q < 8; q++ )
14739
1/2
✓ Branch 0 taken 212992 times.
✗ Branch 1 not taken.
212992 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14740 26624 return qe_invalid;
14741
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if ( guy_cversion < 4 )
14742 {
14743 if ( tempguy.type == eeKEESE )
14744 {
14745
14746 if ( !tempguy.attributes[0] )
14747 {
14748 tempguy.attributes[15] = 120;
14749 tempguy.attributes[16] = 16;
14750
14751 }
14752 }
14753 if ( tempguy.type == eePEAHAT )
14754 {
14755 tempguy.attributes[15] = 80;
14756 tempguy.attributes[16] = 16;
14757 }
14758
14759 if ( tempguy.type == eeGHINI )
14760 {
14761 tempguy.attributes[15] = 120;
14762 tempguy.attributes[16] = 10;
14763 }
14764
14765 }
14766 110080 }
14767
14768
14769
14770 //default weapon sprites (quest version < 2.54)
14771 //port over old defaults -Z
14772
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 32)
14773 {
14774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14775 {
14776
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14777 {
14778 case wNone:
14779 86878 tempguy.wpnsprite = 0; break;
14780
14781 case wSword:
14782 case wBeam:
14783 case wBrang:
14784 case wBomb:
14785 case wSBomb:
14786 case wLitBomb:
14787 case wLitSBomb:
14788 case wArrow:
14789 case wFire:
14790 case wWhistle:
14791 case wBait:
14792 case wWand:
14793 case wMagic:
14794 case wCatching:
14795 case wWind:
14796 case wRefMagic:
14797 case wRefFireball:
14798 case wRefRock:
14799 case wHammer:
14800 case wHookshot:
14801 case wHSHandle:
14802 case wHSChain:
14803 case wSSparkle:
14804 case wFSparkle:
14805 case wSmack:
14806 case wPhantom:
14807 case wCByrna:
14808 case wRefBeam:
14809 case wStomp:
14810 case lwMax:
14811 case wScript1:
14812 case wScript2:
14813 case wScript3:
14814 case wScript4:
14815 case wScript5:
14816 case wScript6:
14817 case wScript7:
14818 case wScript8:
14819 case wScript9:
14820 case wScript10:
14821 case wIce:
14822 //Cannot use any of these weapons yet.
14823 tempguy.wpnsprite = -1;
14824 break;
14825
14826 case wEnemyWeapons:
14827 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14828
14829 801 case ewArrow: tempguy.wpnsprite = 19; break;
14830 691 case ewBrang: tempguy.wpnsprite = 4; break;
14831 1900 case ewSword: tempguy.wpnsprite = 20; break;
14832 1291 case ewRock: tempguy.wpnsprite = 18; break;
14833 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14834 206 case ewBomb: tempguy.wpnsprite = 78; break;
14835 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14836 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14837 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14838 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14839 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14840 229 case ewWind: tempguy.wpnsprite = 36; break;
14841 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14842 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14843 case ewIce: tempguy.wpnsprite = 83; break;
14844 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14845
14846
14847 default: break; //No assign.
14848 }
14849 102400 }
14850 102400 }
14851
14852 //default weapon fire sound (quest version < 2.54)
14853 //port over old defaults and zero new data. -Z
14854
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 34)
14855 {
14856
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14857 {
14858 3276800 tempguy.movement[q] = 0;
14859 3276800 tempguy.new_weapon[q] = 0;
14860
14861 3276800 }
14862
14863 //NPC Script attributes.
14864 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14865
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14866
14867
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14868
14869 //old default sounds
14870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14871 {
14872
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14873 {
14874 case wNone:
14875 86878 tempguy.firesfx = 0; break;
14876
14877 case wSword:
14878 case wBeam:
14879 case wBrang:
14880 case wBomb:
14881 case wSBomb:
14882 case wLitBomb:
14883 case wLitSBomb:
14884 case wArrow:
14885 case wFire:
14886 case wWhistle:
14887 case wBait:
14888 case wWand:
14889 case wMagic:
14890 case wCatching:
14891 case wWind:
14892 case wRefMagic:
14893 case wRefFireball:
14894 case wRefRock:
14895 case wHammer:
14896 case wHookshot:
14897 case wHSHandle:
14898 case wHSChain:
14899 case wSSparkle:
14900 case wFSparkle:
14901 case wSmack:
14902 case wPhantom:
14903 case wCByrna:
14904 case wRefBeam:
14905 case wStomp:
14906 case lwMax:
14907 case wScript1:
14908 case wScript2:
14909 case wScript3:
14910 case wScript4:
14911 case wScript5:
14912 case wScript6:
14913 case wScript7:
14914 case wScript8:
14915 case wScript9:
14916 case wScript10:
14917 case wIce:
14918 //Cannot use any of these weapons yet.
14919 tempguy.firesfx = -1;
14920 break;
14921
14922 case wEnemyWeapons:
14923 2849 case ewFireball: tempguy.firesfx = 40; break;
14924
14925 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14926 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14927 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14928 1291 case ewRock: tempguy.firesfx = 51; break;
14929 2399 case ewMagic: tempguy.firesfx = 32; break;
14930 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14931 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14932 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14933 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14934 906 case ewFireTrail: tempguy.firesfx = 13; break;
14935 1802 case ewFlame: tempguy.firesfx = 13; break;
14936 229 case ewWind: tempguy.firesfx = 32; break;
14937 325 case ewFlame2: tempguy.firesfx = 13; break;
14938 case ewFlame2Trail: tempguy.firesfx = 13; break;
14939 case ewIce: tempguy.firesfx = 44; break;
14940 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14941
14942 //what about special attacks (e.g. summoning == 56)
14943 default: break; //No assign.
14944 }
14945 102400 }
14946 102400 }
14947
14948 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14949
4/6
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 110080 times.
212480 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14950 {
14951
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14952 102400 }
14953 //Keese and bat halt rates.
14954
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
212480 if ( guyversion < 42 && guy_cversion < 4 )
14955 {
14956
14957
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14958 {
14959
14960
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14961 {
14962 935 tempguy.attributes[15] = 120;
14963 935 tempguy.attributes[16] = 16;
14964
14965 935 }
14966 1299 }
14967
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14968 {
14969 465 tempguy.attributes[15] = 80;
14970 465 tempguy.attributes[16] = 16;
14971 465 }
14972
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14973 {
14974 200 tempguy.attributes[15] = 120;
14975 200 tempguy.attributes[16] = 10;
14976 200 }
14977
14978
14979 102400 }
14980
14981
14982 //miscellaneous other corrections
14983 //fix the mirror wizzrobe -DD
14984
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 7)
14985 {
14986 if(i == eMWIZ)
14987 {
14988 tempguy.attributes[1] = 0;
14989 tempguy.attributes[3] = 1;
14990 }
14991 }
14992
14993
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 8)
14994 {
14995 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14996 {
14997 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14998 tempguy.attributes[4] = 4; //neck length in segments
14999 tempguy.attributes[5] = 8; //neck offset from first body tile
15000 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
15001 tempguy.attributes[7] = 168; //head offset from first body tile
15002 tempguy.attributes[8] = 228; //flying head offset from first body tile
15003
15004 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15005 {
15006 tempguy.attributes[5] += 10; //neck offset from first body tile
15007 tempguy.attributes[7] -= 12; //head offset from first body tile
15008 }
15009 }
15010 }
15011
15012
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15013 {
15014 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
15015 tempguy.bosspal = spDIG;
15016 }
15017
15018
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 11) // December 2007 - Spinning Tile fix
15019 {
15020 if(tempguy.type==eeSPINTILE)
15021 {
15022 tempguy.flags |= guy_superman;
15023 tempguy.item_set = 0; // Don't drop items
15024 tempguy.step = 300;
15025 }
15026 }
15027
15028
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15029 {
15030 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15031 {
15032 if(tempguy.type==eeROPE)
15033 {
15034 tempguy.flags &= ~guy_flashing;
15035 }
15036 }
15037
15038 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15039 {
15040 if(tempguy.type==eeBUBBLE)
15041 {
15042 tempguy.flags &= ~guy_flashing;
15043 }
15044 }
15045
15046 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
15047 {
15048 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15049 {
15050 tempguy.flags |= guy_blinking;
15051 }
15052
15053 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15054 {
15055 tempguy.flags |= guy_transparent;
15056 }
15057 }
15058 }
15059
15060
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15061 {
15062 if(i==gFIRE)
15063 {
15064 tempguy.e_anim = aFLIP;
15065 tempguy.e_frate = 24;
15066 }
15067
15068 if(i==gFAIRY)
15069 {
15070 tempguy.e_anim = a2FRM;
15071 tempguy.e_frate = 16;
15072 }
15073 }
15074
15075
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15076 {
15077 if(i==0) Z_message("Updating guys to version 16...\n");
15078
15079 update_guy_1(&tempguy);
15080
15081 if(i==eMPOLSV)
15082 {
15083 tempguy.defense[edefARROW] = edCHINK;
15084 tempguy.defense[edefMAGIC] = ed1HKO;
15085 tempguy.defense[edefREFMAGIC] = ed1HKO;
15086 }
15087 }
15088
15089
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 17) // December 2009
15090 {
15091 if(tempguy.type==eePROJECTILE)
15092 {
15093 tempguy.attributes[0] = 0;
15094 }
15095 }
15096
15097
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 18) // January 2010
15098 {
15099 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
15100 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
15101
15102 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
15103 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
15104
15105 if(tempguy.type == eeAQUA)
15106 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15107 else if(tempguy.type == eeMANHAN)
15108 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15109 else if(tempguy.type==eePATRA)
15110 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15111 else if(tempguy.type==eeGHOMA)
15112 {
15113 for(int32_t j=0; j<edefLAST; j++)
15114 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15115
15116 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
15117
15118 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15119
15120 tempguy.attributes[0]--;
15121 }
15122 else if(tempguy.type == eeGLEEOK)
15123 {
15124 for(int32_t j=0; j<edefLAST; j++)
15125 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15126
15127 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15128 }
15129 else if(tempguy.type == eeARMOS)
15130 {
15131 tempguy.type=eeWALK;
15132 tempguy.hrate = 0;
15133 tempguy.attributes[9] = tempguy.attributes[0];
15134 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15135 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15136 tempguy.attributes[8] = e9tARMOS;
15137 }
15138 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
15139 {
15140 tempguy.type=eeWALK;
15141 tempguy.hrate = 0;
15142 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
15143 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
15144 }
15145
15146 // Spawn animation flags
15147 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
15148 tempguy.flags |= guy_fade_flicker;
15149 else
15150 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
15151 }
15152
15153
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 20) // April 2010
15154 {
15155 if(tempguy.type == eeTRAP)
15156 {
15157 tempguy.attributes[1] = tempguy.attributes[9];
15158
15159 if(tempguy.attributes[9]>=1)
15160 {
15161 tempguy.attributes[0]++;
15162 }
15163
15164 tempguy.attributes[9] = 0;
15165 }
15166
15167 // Bomb Blast fix
15168 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15169 tempguy.weapon = ewLitBomb;
15170 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15171 tempguy.weapon = ewLitSBomb;
15172 }
15173
15174
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 21) // September 2011
15175 {
15176 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
15177 {
15178 if(tempguy.type == eeKEESETRIB)
15179 {
15180 tempguy.type = eeKEESE;
15181 tempguy.attributes[1] = e2tKEESETRIB;
15182 tempguy.attributes[0] = 0;
15183 }
15184
15185 tempguy.rate = 2;
15186 tempguy.hrate = 8;
15187 tempguy.homing = 0;
15188 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15189 }
15190 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15191 {
15192 if(tempguy.type == eePEAHAT)
15193 {
15194 tempguy.rate = 4;
15195 tempguy.step = 62;
15196 }
15197 else
15198 tempguy.step = 25;
15199
15200 tempguy.hrate = 8;
15201 tempguy.homing = 0;
15202 }
15203 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15204 {
15205 if(tempguy.type == eeMANHAN)
15206 tempguy.step=50;
15207
15208 tempguy.hrate = 16;
15209 tempguy.homing = 0;
15210 }
15211 else if(tempguy.type == eeGLEEOK)
15212 {
15213 tempguy.rate = 2;
15214 tempguy.homing = 0;
15215 tempguy.hrate = 9;
15216 tempguy.step=89;
15217 }
15218 else if(tempguy.type == eeGHINI)
15219 {
15220 tempguy.rate = 4;
15221 tempguy.hrate = 12;
15222 tempguy.step=62;
15223 tempguy.homing = 0;
15224 }
15225
15226 // Bigdig random rate fix
15227 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15228 {
15229 tempguy.rate = 2;
15230 }
15231 }
15232
15233
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 24) // November 2012
15234 {
15235 if(tempguy.type==eeLANM)
15236 tempguy.attributes[2] = 1;
15237 else if(tempguy.type==eeMOLD)
15238 tempguy.attributes[1] = 0;
15239 }
15240
15241
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15242 {
15243
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15244 {
15245 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15246 101000 }
15247
15248 102400 }
15249 // does not seem to solve the issue!
15250
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if ( Header->zelda_version <= 0x210 )
15251 {
15252 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15253 if ( tempguy.type == eeDONGO )
15254 {
15255 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15256 }
15257 }
15258
15259
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion >= 42)
15260 {
15261
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 2560 times.
110080 if(guyversion >= 47)
15262 {
15263
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.moveflags),f))
15264 {
15265 return qe_invalid;
15266 }
15267 107520 }
15268 else
15269 {
15270 byte fl;
15271
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15272 {
15273 return qe_invalid;
15274 }
15275 2560 tempguy.moveflags = (move_flags)fl;
15276 }
15277 110080 }
15278 else
15279 {
15280
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15281 {
15282 //No gravity; floats over pits
15283 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15284 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15285 //Special (bosses, etc)
15286 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15287 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15288 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15289 80670 tempguy.moveflags = move_can_pitwalk;
15290 80670 break;
15291 //No gravity, but falls in pits
15292 case eeLEV:
15293 958 tempguy.moveflags = move_can_pitfall;
15294 958 break;
15295 //Bosses that respect pits
15296 case eeDONGO:
15297 642 tempguy.moveflags = move_obeys_grav;
15298 642 break;
15299 case eeLANM:
15300 498 tempguy.moveflags = move_none;
15301 498 break;
15302 //Gravity, floats over pits
15303 case eeWIZZ: case eeWALLM: case eeGHINI:
15304 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15305 2717 break;
15306 //Gravity and falls in pits
15307 case eeWALK:
15308
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15309 1224 break;
15310 [[fallthrough]];
15311 case eeOTHER:
15312 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15313 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15314 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15315 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15316 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15317 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15318 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15319 15691 }
15320 }
15321
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 43)
15322 {
15323
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15324 {
15325 //No gravity; floats over pits
15326 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15327 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15328 //Special (bosses, etc)
15329 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15330 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15331 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15332 case eeWIZZ: case eeWALLM: case eeGHINI:
15333 //Gravity, floats over pits
15334 83387 tempguy.moveflags |= move_can_waterwalk;
15335 83387 tempguy.moveflags |= move_can_pitwalk;
15336 83387 break;
15337 }
15338 102400 }
15339
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if (guyversion < 44)
15340 {
15341
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15342 {
15343 913 tempguy.flags |= guy_fade_instant;
15344 913 }
15345 102400 }
15346
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if (guyversion > 44)
15347 {
15348
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_shadow),f))
15349 {
15350 return qe_invalid;
15351 }
15352
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_death),f))
15353 {
15354 return qe_invalid;
15355 }
15356
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_spawn),f))
15357 {
15358 return qe_invalid;
15359 }
15360 110080 }
15361 else
15362 {
15363
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15364 102400 tempguy.spr_death = iwDeath;
15365 102400 tempguy.spr_spawn = iwSpawn;
15366 }
15367
15368
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 46)
15369 {
15370
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15371 {
15372 695 tempguy.moveflags |= move_can_waterwalk;
15373 695 }
15374 102400 }
15375
15376
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 104960 times.
212480 if (guyversion < 47)
15377 {
15378
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15379 {
15380 574 tempguy.flags |= guy_ignore_kill_all;
15381 574 }
15382 104960 }
15383
15384
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 125952 times.
212480 if (guyversion < 49)
15385 {
15386
8/8
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 109494 times.
✓ Branch 2 taken 15984 times.
✓ Branch 3 taken 474 times.
✓ Branch 4 taken 15499 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 14969 times.
125952 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15387 {
15388
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 715 times.
✓ Branch 3 taken 61 times.
1489 switch (tempguy.attributes[7]) {
15389 case 0: //Sword
15390 713 tempguy.attributes[7] = e8tSWORD;
15391 713 break;
15392 case 1: //Item
15393 715 tempguy.attributes[7] = e8tITEM;
15394 715 break;
15395 case 2: //Both
15396 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15397 61 break;
15398 default: //this can actually happen since Misc8 can be set to any number.
15399 tempguy.attributes[7] = 0;
15400 break;
15401 }
15402 1489 }
15403 125952 }
15404
15405 //these could possible be combined but rather be safe...
15406
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 125952 times.
212480 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15407 {
15408 125952 guy_update_firesfx(tempguy);
15409 125952 }
15410
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 86528 times.
212480 if (guyversion < 52)
15411 {
15412 125952 guy_update_weaponflags(tempguy);
15413 125952 }
15414
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 3072 times.
86528 else if(guyversion < 54)
15415 {
15416
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15417 return qe_invalid;
15418
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15419 return qe_invalid;
15420
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15421 return qe_invalid;
15422
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15423 return qe_invalid;
15424
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15425 return qe_invalid;
15426
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15427 return qe_invalid;
15428
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15429 return qe_invalid;
15430
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15431 return qe_invalid;
15432
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15433 return qe_invalid;
15434
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15435 return qe_invalid;
15436
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15437 return qe_invalid;
15438
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15439 return qe_invalid;
15440 int32_t temp_step;
15441
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&temp_step, f))
15442 return qe_invalid;
15443 3072 tempguy.weap_data.step = zslongToFix(temp_step*100);
15444
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 3072 times.
18432 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15445 {
15446
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15447 return qe_invalid;
15448
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15449 return qe_invalid;
15450 15360 }
15451 3072 }
15452
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 86528 times.
212480 if (guyversion < 53)
15453 {
15454 125952 guy_update_weaponspecialsfx(tempguy);
15455 125952 }
15456 else
15457 {
15458
1/2
✓ Branch 0 taken 86528 times.
✗ Branch 1 not taken.
86528 if (!p_getc(&(tempguy.specialsfx), f))
15459 return qe_invalid;
15460 }
15461
15462
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 129024 times.
212480 if(guyversion >= 54)
15463 {
15464
1/2
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
83456 if(auto ret = read_weap_data(tempguy.weap_data, f))
15465 return ret;
15466 83456 }
15467 else
15468 {
15469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129024 times.
129024 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15470 129024 tempguy.weap_data.flags |= wdata_set_step;
15471
2/2
✓ Branch 0 taken 127437 times.
✓ Branch 1 taken 1587 times.
129024 if(tempguy.weapon == ewRock)
15472 1587 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15473 }
15474
15475
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15476 {
15477 tempguy.script = 0;
15478 for(int q = 0; q < 8; ++q)
15479 tempguy.initD[q] = 0;
15480 }
15481 212480 guysbuf[i] = tempguy;
15482 212480 }
15483 415 }
15484
15485 415 return 0;
15486 497 }
15487
15488 void update_guy_1(guydata *tempguy) // November 2009
15489 {
15490 bool doesntcount = false;
15491 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15492
15493 switch(tempguy->type)
15494 {
15495 case 1: //eeWALK
15496 switch(tempguy->attributes[9])
15497 {
15498 case 0: //Stalfos
15499 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15500 tempguy->attributes[0]=4;
15501
15502 break;
15503
15504 case 1: //Darknut
15505 goto darknuts;
15506 break;
15507 }
15508
15509 tempguy->attributes[9] = 0;
15510 break;
15511
15512 case 2: //eeSHOOT
15513 tempguy->type = eeWALK;
15514
15515 switch(tempguy->attributes[9])
15516 {
15517 case 0: //Octorok
15518 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15519 {
15520 tempguy->attributes[0]=e1tFIREOCTO;
15521 tempguy->attributes[1]=e2tFIREOCTO;
15522 }
15523 else tempguy->attributes[0] = 0;
15524
15525 tempguy->attributes[5]=tempguy->attributes[3];
15526 tempguy->attributes[3]=tempguy->attributes[2];
15527 tempguy->attributes[2]=0;
15528 break;
15529
15530 case 1: // Moblin
15531 tempguy->attributes[0] = 0;
15532 break;
15533
15534 case 2: //Lynel
15535 tempguy->attributes[5]=tempguy->attributes[0]+1;
15536 tempguy->attributes[0]=0;
15537 break;
15538
15539 case 3: //Stalfos 2
15540 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15541 tempguy->attributes[0]=e1t4SHOTS;
15542 else tempguy->attributes[0] = 0;
15543
15544 break;
15545
15546 case 4: //Darknut 5
15547 darknuts:
15548 tempguy->defense[edefFIRE] = edIGNORE;
15549 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15550 tempguy->defense[edefHOOKSHOT] = 0;
15551 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15552 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15553
15554 if(tempguy->attributes[0]==1)
15555 tempguy->attributes[0]=2;
15556 else if(tempguy->attributes[0]==2)
15557 {
15558 tempguy->attributes[3]=tempguy->attributes[2];
15559 tempguy->attributes[2]=tempguy->attributes[1];
15560 tempguy->attributes[1]=e2tSPLIT;
15561 tempguy->attributes[0] = 0;
15562 }
15563 else tempguy->attributes[0] = 0;
15564
15565 tempguy->flags |= guy_shield_front;
15566
15567 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15568 tempguy->flags &= ~guy_bkshield;
15569 else
15570 tempguy->flags |= guy_bkshield;
15571
15572 break;
15573 }
15574
15575 tempguy->attributes[9] = 0;
15576 break;
15577
15578 /*
15579 case 9: //eeARMOS
15580 tempguy->family = eeWALK;
15581 break;
15582 */
15583 case 11: //eeGEL
15584 case 33: //eeGELTRIB
15585 if(tempguy->type==33)
15586 {
15587 tempguy->attributes[3] = 1;
15588
15589 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15590 tempguy->attributes[2] = tempguy->attributes[1];
15591
15592 tempguy->attributes[1] = e2tTRIBBLE;
15593 }
15594 else
15595 {
15596 tempguy->attributes[3] = 0;
15597 tempguy->attributes[2] = 0;
15598 tempguy->attributes[1] = 0;
15599 }
15600
15601 tempguy->type = eeWALK;
15602
15603 if(tempguy->attributes[0])
15604 {
15605 tempguy->attributes[0]=1;
15606 tempguy->weapon = ewFireTrail;
15607 }
15608
15609 break;
15610
15611 case 34: //eeZOLTRIB
15612 case 12: //eeZOL
15613 tempguy->attributes[3]=tempguy->attributes[2];
15614 tempguy->attributes[2]=tempguy->attributes[1];
15615 tempguy->type = eeWALK;
15616 tempguy->attributes[1]=e2tSPLITHIT;
15617
15618 if(tempguy->attributes[0])
15619 {
15620 tempguy->attributes[0]=1;
15621 tempguy->weapon = ewFireTrail;
15622 }
15623
15624 break;
15625
15626 case 13: //eeROPE
15627 tempguy->type = eeWALK;
15628 tempguy->attributes[8] = e9tROPE;
15629
15630 if(tempguy->attributes[0])
15631 {
15632 tempguy->attributes[3] = tempguy->attributes[2];
15633 tempguy->attributes[2] = tempguy->attributes[1];
15634 tempguy->attributes[1] = e2tBOMBCHU;
15635 }
15636
15637 tempguy->attributes[0] = 0;
15638 break;
15639
15640 case 14: //eeGORIYA
15641 tempguy->type = eeWALK;
15642
15643 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15644
15645 break;
15646
15647 case 17: //eeBUBBLE
15648 tempguy->type = eeWALK;
15649 tempguy->attributes[7] = tempguy->attributes[1];
15650 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15651 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15652
15653 //fallthrogh
15654 case eeTRAP:
15655 case eeROCK:
15656 doesntcount = true;
15657 break;
15658
15659 case 35: //eeVIRETRIB
15660 case 18: //eeVIRE
15661 tempguy->type = eeWALK;
15662 tempguy->attributes[3]=tempguy->attributes[2];
15663 tempguy->attributes[2]=tempguy->attributes[1];
15664 tempguy->attributes[1]=e2tSPLITHIT;
15665 tempguy->attributes[8]=e9tVIRE;
15666 break;
15667
15668 case 19: //eeLIKE
15669 tempguy->type = eeWALK;
15670 tempguy->attributes[6] = e7tEATITEMS;
15671 tempguy->attributes[7]=95;
15672 break;
15673
15674 case 20: //eePOLSV
15675 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15676 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15677 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15678 tempguy->defense[edefARROW] = ed1HKO;
15679 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15680 tempguy->type = eeWALK;
15681 tempguy->attributes[8] = e9tPOLSVOICE;
15682 tempguy->rate = 4;
15683 tempguy->homing = 32;
15684 tempguy->hrate = 10;
15685 tempguy->grumble = 0;
15686 break;
15687
15688 case eeWIZZ:
15689 if(tempguy->attributes[3])
15690 {
15691 for(int32_t i=0; i < edefLAST; i++)
15692 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15693 }
15694 else
15695 {
15696 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15697 tempguy->defense[edefMAGIC] = edCHINK;
15698 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15699 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15700 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15701 }
15702
15703 break;
15704
15705 case eePEAHAT:
15706 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15707
15708 if(!(tempguy->flags & guy_bhit))
15709 tempguy->defense[edefBRANG] = edSTUNONLY;
15710
15711 break;
15712
15713 case eeLEV:
15714 tempguy->defense[edefSTOMP] = edCHINK;
15715 break;
15716 }
15717
15718 // Old flags
15719 if(tempguy->flags & guy_superman)
15720 {
15721 for(int32_t i = 0; i < edefLAST; i++)
15722 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15723 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15724 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15725 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15726 }
15727
15728 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15729
15730 if(doesntcount)
15731 tempguy->flags |= (guy_doesnt_count);
15732 }
15733
15734 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15735 {
15736 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15737
15738 byte tempbyte, padding;
15739 word wpadding;
15740 int32_t extras, secretcombos;
15741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15742 {
15743 return qe_invalid;
15744 }
15745
15746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15747 return qe_invalid;
15748 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15749
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15750
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15751
15752
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15753 {
15754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15755 {
15756 return qe_invalid;
15757 }
15758
15759 22176 temp_mapscr->str=tempbyte;
15760 22176 }
15761 else
15762 {
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15764 {
15765 return qe_invalid;
15766 }
15767 }
15768
15769
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15770 {
15771 return qe_invalid;
15772 }
15773
15774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15775 {
15776 return qe_invalid;
15777 }
15778
15779
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15780 {
15781 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15782 528504 }
15783 else
15784 {
15785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15786 return qe_invalid;
15787 }
15788
15789
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15790
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15791 {
15792
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15793 {
15794 return qe_invalid;
15795 }
15796 22176 }
15797
15798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15799 {
15800 return qe_invalid;
15801 }
15802
15803
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15804 {
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15806 {
15807 return qe_invalid;
15808 }
15809 24896 }
15810
15811
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15812 {
15813
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15814 {
15815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15816 {
15817 return qe_invalid;
15818 }
15819 1951056 }
15820 650352 }
15821 else
15822 {
15823 528504 temp_mapscr->tilewarptype[1]=0;
15824 528504 temp_mapscr->tilewarptype[2]=0;
15825 528504 temp_mapscr->tilewarptype[3]=0;
15826 }
15827
15828
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15829 {
15830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15831 {
15832 return qe_invalid;
15833 }
15834 1156680 }
15835
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15837 {
15838 return qe_invalid;
15839 }
15840
15841 1178856 temp_mapscr->warpreturnx[1]=0;
15842 1178856 temp_mapscr->warpreturnx[2]=0;
15843 1178856 temp_mapscr->warpreturnx[3]=0;
15844
15845
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15846 {
15847
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15848 {
15849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15850 {
15851 return qe_invalid;
15852 }
15853 1951056 }
15854 650352 }
15855
15856
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15857 {
15858 return qe_invalid;
15859 }
15860
15861 1178856 temp_mapscr->warpreturny[1]=0;
15862 1178856 temp_mapscr->warpreturny[2]=0;
15863 1178856 temp_mapscr->warpreturny[3]=0;
15864
15865
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15866 {
15867
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15868 {
15869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15870 {
15871 return qe_invalid;
15872 }
15873 1951056 }
15874
15875
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15876 {
15877
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15878 {
15879 return qe_invalid;
15880 }
15881 650352 }
15882 else
15883 {
15884 byte temp;
15885
15886 if(!p_getc(&temp,f))
15887 {
15888 return qe_invalid;
15889 }
15890
15891 temp_mapscr->warpreturnc=temp<<8|temp;
15892 }
15893 650352 }
15894
15895
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15896
15897 {
15898 return qe_invalid;
15899 }
15900
15901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15902 {
15903 return qe_invalid;
15904 }
15905
15906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15907 {
15908 return qe_invalid;
15909 }
15910
15911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15912 {
15913 return qe_invalid;
15914 }
15915
15916
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15917 {
15918
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15919 {
15920 return qe_invalid;
15921 }
15922 650352 }
15923 else
15924 {
15925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15926 {
15927 return qe_invalid;
15928 }
15929
15930 528504 temp_mapscr->color = (word) tempbyte;
15931 }
15932
15933
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15934 {
15935 return qe_invalid;
15936 }
15937
15938
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15939 {
15940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15941 {
15942 return qe_invalid;
15943
15944 }
15945 4715424 }
15946
15947
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15948 {
15949
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15950 {
15951 return qe_invalid;
15952 }
15953
15954 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15955
15956
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15957 {
15958 for(int32_t i=1; i<4; i++)
15959 {
15960 if(!p_getc(&(tempbyte),f))
15961 {
15962 return qe_invalid;
15963 }
15964
15965 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15966 }
15967 }
15968 else
15969 {
15970 528504 temp_mapscr->tilewarpdmap[1]=0;
15971 528504 temp_mapscr->tilewarpdmap[2]=0;
15972 528504 temp_mapscr->tilewarpdmap[3]=0;
15973 }
15974 528504 }
15975 else
15976 {
15977
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15978 {
15979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15980 {
15981 return qe_invalid;
15982 }
15983 2601408 }
15984 }
15985
15986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15987 {
15988 return qe_invalid;
15989 }
15990
15991
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15992 {
15993
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15994 {
15995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15996 {
15997 return qe_invalid;
15998 }
15999 1951056 }
16000 650352 }
16001 else
16002 {
16003 528504 temp_mapscr->tilewarpscr[1]=0;
16004 528504 temp_mapscr->tilewarpscr[2]=0;
16005 528504 temp_mapscr->tilewarpscr[3]=0;
16006 }
16007
16008
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
16009 {
16010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16011 {
16012 return qe_invalid;
16013 }
16014 650352 }
16015 else
16016 {
16017 528504 temp_mapscr->tilewarpoverlayflags=0;
16018 }
16019
16020
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
16021 {
16022 return qe_invalid;
16023 }
16024
16025
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16026 {
16027
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
16028 {
16029 return qe_invalid;
16030 }
16031
16032 24896 }
16033
16034
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
16035 {
16036 if(!p_getc(&padding,f))
16037 {
16038 return qe_invalid;
16039 }
16040 }
16041
16042
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
16043 {
16044
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
16045 {
16046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
16047 {
16048 return qe_invalid;
16049 }
16050
16051 221760 temp_mapscr->enemy[k]=tempbyte;
16052
16053 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
16054 // from corrupting when 1.90 saved the quest.
16055 // https://discord.com/channels/876899628556091432/1287580827164737658
16056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
16057 {
16058
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
16059 {
16060 temp_mapscr->enemy[k] = 0;
16061 }
16062 221760 }
16063 221760 }
16064 else
16065 {
16066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16067 {
16068 return qe_invalid;
16069 }
16070 }
16071
16072
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16073 {
16074 //using enumerations here is dangerous
16075 //very easy to break old quests -DD
16076
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16077 {
16078 1342 temp_mapscr->enemy[k]+=5;
16079 1342 }
16080
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16081 {
16082 94 temp_mapscr->enemy[k]+=1;
16083 94 }
16084 221760 }
16085
16086
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
16087 {
16088
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
16089 {
16090 275905 temp_mapscr->enemy[k]+=10;
16091 275905 }
16092 5285040 }
16093 //don't read in any invalid data
16094
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16095 {
16096 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16097 450 temp_mapscr->enemy[k] = 0;
16098 450 }
16099 11788560 }
16100
16101
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
16102 {
16103 return qe_invalid;
16104 }
16105
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
16107 {
16108 return qe_invalid;
16109 }
16110
16111
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16112 {
16113
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
16114 {
16115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16116 {
16117 return qe_invalid;
16118 }
16119 1951056 }
16120 650352 }
16121 else
16122 {
16123 528504 temp_mapscr->sidewarptype[1]=0;
16124 528504 temp_mapscr->sidewarptype[2]=0;
16125 528504 temp_mapscr->sidewarptype[3]=0;
16126 }
16127
16128
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
16129 {
16130
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16131 {
16132 return qe_invalid;
16133 }
16134 650352 }
16135 else
16136 {
16137 528504 temp_mapscr->sidewarpoverlayflags=0;
16138 }
16139
16140
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16141 {
16142 return qe_invalid;
16143 }
16144
16145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16146 {
16147 return qe_invalid;
16148 }
16149
16150
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16151 {
16152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
16153 {
16154 return qe_invalid;
16155 }
16156 4715424 }
16157
16158
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16159 {
16160 return qe_invalid;
16161 }
16162
16163
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16164 {
16165
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
16166 {
16167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16168 {
16169 return qe_invalid;
16170 }
16171 1951056 }
16172 650352 }
16173 else
16174 {
16175 528504 temp_mapscr->sidewarpscr[1]=0;
16176 528504 temp_mapscr->sidewarpscr[2]=0;
16177 528504 temp_mapscr->sidewarpscr[3]=0;
16178 }
16179
16180
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16181 {
16182
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16183 {
16184 return qe_invalid;
16185 }
16186
16187 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16188
16189
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16190 {
16191 for(int32_t i=1; i<4; i++)
16192 {
16193 if(!p_getc(&(tempbyte),f))
16194 {
16195 return qe_invalid;
16196 }
16197
16198 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16199 }
16200 }
16201 else
16202 {
16203 528504 temp_mapscr->sidewarpdmap[1]=0;
16204 528504 temp_mapscr->sidewarpdmap[2]=0;
16205 528504 temp_mapscr->sidewarpdmap[3]=0;
16206 }
16207 528504 }
16208 else
16209 {
16210
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16213 {
16214 return qe_invalid;
16215 }
16216 2601408 }
16217 }
16218
16219
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16220 {
16221
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16222 {
16223 return qe_invalid;
16224 }
16225 650352 }
16226 528504 else temp_mapscr->sidewarpindex = 0;
16227
16228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16229 {
16230 return qe_invalid;
16231 }
16232
16233 1178856 byte old_combo_page = 0;
16234
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16235 {
16236
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16237 {
16238 return qe_invalid;
16239 }
16240
16241
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16242 {
16243 24624 old_combo_pages[scrind] = old_combo_page;
16244 24624 }
16245 24896 }
16246
16247
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16248 {
16249 return qe_invalid;
16250 }
16251
16252
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16253 {
16254 return qe_invalid;
16255 }
16256
16257
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16258 {
16259 return qe_invalid;
16260 }
16261
16262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16263 {
16264 return qe_invalid;
16265 }
16266
16267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16268 {
16269 return qe_invalid;
16270 }
16271
16272
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16273 //if (version>2)
16274 {
16275
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16276 {
16277 return qe_invalid;
16278 }
16279 650352 }
16280
16281
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16282 {
16283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16284 {
16285 return qe_invalid;
16286 }
16287
16288
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16289 return qe_invalid;
16290 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16291
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16292 return qe_invalid;
16293 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16294 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16295
16296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16297 {
16298 temp_mapscr->flags5 &= ~32;
16299 temp_mapscr->noreset |= 48;
16300 }
16301
16302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16303 {
16304 if(temp_mapscr->noreset&1)
16305 {
16306 temp_mapscr->noreset|=8192;
16307 }
16308
16309 if(temp_mapscr->nocarry&1)
16310 {
16311 temp_mapscr->nocarry|=8192;
16312 temp_mapscr->nocarry&=~1;
16313 }
16314 }
16315 650352 }
16316 else
16317 {
16318 528504 temp_mapscr->flags5 = 0;
16319 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16320 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16321 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16322 }
16323
16324
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16325 {
16326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16327 {
16328 return qe_invalid;
16329 }
16330 650352 }
16331
16332
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16333 {
16334
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16335 {
16336 return qe_invalid;
16337 }
16338
16339
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16340 {
16341 return qe_invalid;
16342 }
16343
16344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16345 {
16346 return qe_invalid;
16347 }
16348
16349
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16350 {
16351 return qe_invalid;
16352 }
16353
16354
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16355 {
16356 return qe_invalid;
16357 }
16358 650352 }
16359 else
16360 {
16361 528504 temp_mapscr->csensitive=1;
16362 }
16363
16364
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16365 {
16366
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16367 {
16368 994 temp_mapscr->bosssfx=
16369
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16370 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16371 WAV_ROAR;
16372 994 }
16373
16374
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16375 {
16376 170 temp_mapscr->oceansfx=WAV_SEA;
16377 170 }
16378
16379 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16380 ? 0 : WAV_SECRET;
16381
16382 528504 temp_mapscr->flags3 &= ~66; //64|2
16383 528504 temp_mapscr->flags2 &= ~32;
16384 528504 temp_mapscr->flags &= ~136; // 128|8
16385 528504 }
16386 else
16387 {
16388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16389 {
16390 return qe_invalid;
16391 }
16392
16393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16394 {
16395 return qe_invalid;
16396 }
16397
16398
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16399 {
16400 return qe_invalid;
16401 }
16402 }
16403
16404
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16405 {
16406 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16407 528504 }
16408 else
16409 {
16410
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16411 {
16412 return qe_invalid;
16413 }
16414 }
16415
16416
16417
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16418 {
16419
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16420 {
16421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16422 {
16423 return qe_invalid;
16424 }
16425 6940080 }
16426
16427
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16428 {
16429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16430 {
16431 return qe_invalid;
16432 }
16433 6940080 }
16434 1156680 }
16435
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16436 {
16437 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16438 {
16439 return qe_invalid;
16440 }
16441
16442 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16443 {
16444 return qe_invalid;
16445 }
16446
16447 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16448 {
16449 return qe_invalid;
16450 }
16451
16452 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16453
16454 {
16455 return qe_invalid;
16456 }
16457 }
16458
16459
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16460 {
16461
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16462 {
16463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16464 {
16465 return qe_invalid;
16466 }
16467 16320 }
16468
16469
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16470 {
16471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16472 {
16473 return qe_invalid;
16474 }
16475 16320 }
16476
16477
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16478 {
16479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16480 {
16481 return qe_invalid;
16482 }
16483 16320 }
16484
16485
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16486 {
16487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16488 {
16489 return qe_invalid;
16490 }
16491 16320 }
16492
16493
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16494 {
16495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16496 {
16497 return qe_invalid;
16498 }
16499 16320 }
16500
16501
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16502 {
16503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16504 {
16505 return qe_invalid;
16506 }
16507 16320 }
16508 2720 }
16509
16510
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16511 {
16512
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16513 {
16514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16515 {
16516 return qe_invalid;
16517 }
16518 6940080 }
16519 1156680 }
16520
16521
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16522 {
16523
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16524 {
16525
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16526 {
16527 return qe_invalid;
16528 }
16529 2720 }
16530
16531
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16532 {
16533 return qe_invalid;
16534 }
16535 1156680 }
16536
16537
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16538 {
16539 22176 extras=15;
16540 22176 }
16541
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16542 {
16543 extras=11;
16544 }
16545
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16546 {
16547 extras=32;
16548 }
16549
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16550 {
16551 extras=64;
16552 }
16553
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16554 {
16555 2720 extras=62;
16556 2720 }
16557 else
16558
16559 {
16560 1153960 extras=0;
16561 }
16562
16563
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16564 {
16565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16566 {
16567 return qe_invalid;
16568 }
16569 501280 }
16570
16571
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16572 //if (version>3)
16573 {
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16575 {
16576 return qe_invalid;
16577 }
16578
16579
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16580 {
16581 return qe_invalid;
16582 }
16583 650352 }
16584 else
16585 {
16586 528504 temp_mapscr->nextmap=0;
16587 528504 temp_mapscr->nextscr=0;
16588 }
16589
16590
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16591 {
16592 22176 secretcombos=20;
16593 22176 }
16594
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16595 {
16596 secretcombos=256;
16597 }
16598 else
16599 {
16600 1156680 secretcombos=128;
16601 }
16602
16603
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16604 {
16605
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16606 {
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16608 {
16609 return qe_invalid;
16610 }
16611
16612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16613 {
16614 443520 temp_mapscr->secretcombo[k]=tempbyte;
16615 443520 }
16616 443520 }
16617 22176 }
16618 else
16619 {
16620
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16621 {
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16623 {
16624 return qe_invalid;
16625 }
16626
16627 148055040 }
16628 }
16629
16630
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16631 {
16632
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16633 {
16634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16635 {
16636 return qe_invalid;
16637 }
16638 148055040 }
16639
16640
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16641 {
16642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16643 {
16644 return qe_invalid;
16645 }
16646 148055040 }
16647 1156680 }
16648
16649
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16650 {
16651 if(!p_getc(&padding,f))
16652 {
16653 return qe_invalid;
16654 }
16655 }
16656
16657
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16658 {
16659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16660 {
16661 return qe_invalid;
16662 }
16663 207478656 }
16664
16665
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16666 {
16667 if(!p_getc(&padding,f))
16668 {
16669 return qe_invalid;
16670 }
16671
16672 if(!p_getc(&padding,f))
16673 {
16674 return qe_invalid;
16675 }
16676 }
16677
16678
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16679 {
16680
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16681 {
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16683 {
16684 return qe_invalid;
16685 }
16686
16687
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16688 {
16689 if(!p_getc(&tempbyte,f))
16690 {
16691 return qe_invalid;
16692 }
16693
16694 if(!p_getc(&tempbyte,f))
16695 {
16696 return qe_invalid;
16697 }
16698
16699 if(!p_getc(&tempbyte,f))
16700 {
16701 return qe_invalid;
16702 }
16703 }
16704 203575680 }
16705 1156680 }
16706
16707
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16708 {
16709
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16710 {
16711
16712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16713 {
16714 return qe_invalid;
16715 }
16716 203575680 }
16717 1156680 }
16718
16719
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16720 {
16721 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16722 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16723 22176 }
16724
16725
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16726 {
16727 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16728 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16729 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16730 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16731 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16732 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16733 22176 }
16734
16735
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16736 {
16737
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16738 {
16739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16740 {
16741 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16742 {
16743 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16744 }
16745 }
16746 else
16747 {
16748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16749 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16750 {
16751 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16752 3902976 }
16753
16754 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16755 }
16756
16757 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16758 3902976 }
16759 22176 }
16760
16761 /*if(version>12)
16762 {
16763 if(!p_getc(&(temp_mapscr->scrWidth),f))
16764 {
16765 return qe_invalid;
16766 }
16767 if(!p_getc(&(temp_mapscr->scrHeight),f))
16768 {
16769 return qe_invalid;
16770 }
16771 }*/
16772
16773
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16774 {
16775
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16776 {
16777 return qe_invalid;
16778 }
16779 650352 }
16780 else
16781 {
16782 528504 temp_mapscr->screen_midi = -1;
16783 }
16784
16785
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16786 {
16787
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16788 {
16789 return qe_invalid;
16790 }
16791 650352 }
16792 else
16793 {
16794 528504 temp_mapscr->lens_layer = llNORMAL;
16795 }
16796
16797
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16798 {
16799 dword bits;
16800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16801 {
16802 return qe_invalid;
16803 }
16804
16805 int32_t m;
16806 float tempfloat;
16807 word tempw;
16808 650352 temp_mapscr->ffcCountMarkDirty();
16809 650352 temp_mapscr->ffcs.clear();
16810 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16811
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16812 {
16813
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16814 {
16815 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16816
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16817 {
16818 return qe_invalid;
16819 }
16820 274752 tempffc.data = tempw;
16821
16822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16823 {
16824 return qe_invalid;
16825 }
16826
16827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16828 {
16829 return qe_invalid;
16830 }
16831
16832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16833 {
16834 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16835 {
16836 return qe_invalid;
16837 }
16838
16839 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16840
16841 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16842 {
16843 return qe_invalid;
16844 }
16845
16846 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16847
16848 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16849 {
16850 return qe_invalid;
16851 }
16852
16853 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16854
16855 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16856 {
16857 return qe_invalid;
16858 }
16859
16860 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16861
16862 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16863 {
16864 return qe_invalid;
16865 }
16866
16867 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16868
16869 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16870 {
16871 return qe_invalid;
16872 }
16873
16874 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16875 }
16876 else
16877 {
16878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16879 {
16880 return qe_invalid;
16881 }
16882
16883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16884 {
16885 return qe_invalid;
16886 }
16887
16888
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16889 {
16890 return qe_invalid;
16891 }
16892
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16894 {
16895 return qe_invalid;
16896 }
16897
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16899 {
16900 return qe_invalid;
16901 }
16902
16903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16904 {
16905 return qe_invalid;
16906 }
16907 }
16908
16909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16910 {
16911 return qe_invalid;
16912 }
16913
16914
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16915 {
16916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16917 {
16918 return qe_invalid;
16919 }
16920
16921 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16922 274752 tempffc.txsz = (tempbyte>>6)+1;
16923
16924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16925 {
16926 return qe_invalid;
16927 }
16928
16929 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16930 274752 tempffc.tysz = (tempbyte>>6)+1;
16931
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16933 {
16934 return qe_invalid;
16935 }
16936 274752 }
16937 else
16938 {
16939 tempffc.hit_width=16;
16940 tempffc.hit_height=16;
16941 tempffc.txsz=1;
16942 tempffc.tysz=1;
16943 tempffc.flags=ffc_none;
16944 }
16945
16946 274752 tempffc.updateSolid();
16947
16948
16949
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16950 {
16951 tempffc.flags|=ffc_ignoreholdup;
16952 }
16953
16954
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16955 {
16956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16957 {
16958 return qe_invalid;
16959 }
16960 274752 }
16961 else
16962 {
16963 tempffc.script=0;
16964 }
16965
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16967 {
16968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16969 {
16970 return qe_invalid;
16971 }
16972
16973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16974 {
16975 return qe_invalid;
16976 }
16977
16978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16979 {
16980 return qe_invalid;
16981 }
16982
16983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16984 {
16985 return qe_invalid;
16986 }
16987
16988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16989 {
16990 return qe_invalid;
16991 }
16992
16993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16994 {
16995 return qe_invalid;
16996 }
16997
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16999 {
17000 return qe_invalid;
17001 }
17002
17003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
17004 {
17005 return qe_invalid;
17006 }
17007
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
17009 {
17010 return qe_invalid;
17011 }
17012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
17013 {
17014 return qe_invalid;
17015 }
17016 274752 }
17017
17018
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17019 {
17020 tempffc.script = 0;
17021 for(int q = 0; q < 8; ++q)
17022 tempffc.initd[q] = 0;
17023 }
17024
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
17025 {
17026 fixffcs=true;
17027 }
17028 274752 }
17029 20811264 }
17030
17031 650352 temp_mapscr->shrinkToFitFFCs();
17032 650352 }
17033
17034
17035 //add in the new whistle flags
17036
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
17037 {
17038
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
17039 {
17040 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
17041 124 }
17042 528504 }
17043
17044 //2.55 starts here
17045
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
17046 {
17047 // mapscr fields that were never used, so are now removed:
17048 // int32_t npcstrings[10];
17049 // int16_t new_items[10];
17050 // int16_t new_item_x[10];
17051 // int16_t new_item_y[10];
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
17053 {
17054 return qe_invalid;
17055 }
17056 34408 }
17057
17058
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
17059 {
17060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
17061 {
17062 return qe_invalid;
17063 }
17064
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
17065 {
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17067 {
17068 return qe_invalid;
17069 }
17070 275264 }
17071 34408 }
17072
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
17073 {
17074 1144448 temp_mapscr->script = 0;
17075
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17076 1144448 }
17077
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
17078 {
17079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
17080 {
17081 return qe_invalid;
17082 }
17083 34408 }
17084
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
17085 {
17086 1144448 temp_mapscr->preloadscript = 0;
17087 1144448 }
17088
17089
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17090 {
17091
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
17092 {
17093 return qe_invalid;
17094 }
17095
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
17096 {
17097 return qe_invalid;
17098 }
17099 34408 }
17100
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
17101 {
17102 1144448 temp_mapscr->hidelayers = 0;
17103 1144448 temp_mapscr->hidescriptlayers = 0;
17104 1144448 }
17105
17106 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17107 //May be any version before 2.11. -Z
17108 /* --not the roar, the HIT SFX
17109 if ( Header->zelda_version <= 0x210 )
17110 {
17111 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17112 {
17113 temp_mapscr->bosssfx = WAV_ROAR;
17114 }
17115 }
17116 */
17117
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
17118 {
17119
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
17120 temp_mapscr->door[k] = dWALL;
17121 4715424 }
17122
17123 1178856 return 0;
17124 1178856 }
17125 1563056 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
17126 {
17127
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 384200 times.
1563056 if(version < 23)
17128 {
17129 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
17130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
17131 1178856 }
17132 else
17133 {
17134
1/2
✓ Branch 0 taken 384200 times.
✗ Branch 1 not taken.
384200 if(!p_getc(&(temp_mapscr->valid),f))
17135 return qe_invalid;
17136
2/2
✓ Branch 0 taken 193992 times.
✓ Branch 1 taken 190208 times.
384200 if(!(temp_mapscr->valid & mVALID))
17137 {
17138 190208 int map = scrind/MAPSCRS;
17139 190208 int screen = scrind%MAPSCRS;
17140
4/6
✓ Branch 0 taken 183106 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 183106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 183106 times.
190208 if(version > 25 && scrind > -1 && map < map_infos.size())
17141 {
17142 183106 auto const& mapinf = map_infos[map];
17143 //Empty screen, apply defaults
17144
2/2
✓ Branch 0 taken 1098636 times.
✓ Branch 1 taken 183106 times.
1281742 for(int q = 0; q < 6; ++q)
17145 {
17146 1098636 auto layermap = mapinf.autolayers[q];
17147 1098636 temp_mapscr->layermap[q] = layermap;
17148
2/2
✓ Branch 0 taken 1027017 times.
✓ Branch 1 taken 71619 times.
1098636 if(layermap)
17149 71619 temp_mapscr->layerscreen[q] = screen;
17150 1098636 }
17151 183106 temp_mapscr->color = mapinf.autopalette;
17152 183106 }
17153 190208 return 0;
17154 }
17155 uint32_t scr_has_flags;
17156
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_igetl(&scr_has_flags,f))
17157 return qe_invalid;
17158
17159
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 183534 times.
193992 if(scr_has_flags & SCRHAS_ROOMDATA)
17160 {
17161
1/2
✓ Branch 0 taken 183534 times.
✗ Branch 1 not taken.
183534 if(!p_getc(&(temp_mapscr->guy),f))
17162 return qe_invalid;
17163
2/2
✓ Branch 0 taken 183414 times.
✓ Branch 1 taken 120 times.
183534 if(version > 26)
17164 {
17165
1/2
✓ Branch 0 taken 183414 times.
✗ Branch 1 not taken.
183414 if(!p_igetl(&(temp_mapscr->guytile),f))
17166 return qe_invalid;
17167
1/2
✓ Branch 0 taken 183414 times.
✗ Branch 1 not taken.
183414 if(!p_getc(&(temp_mapscr->guycs),f))
17168 return qe_invalid;
17169
1/2
✓ Branch 0 taken 183414 times.
✗ Branch 1 not taken.
183414 if(!p_igetw(&(temp_mapscr->roomflags),f))
17170 return qe_invalid;
17171 183414 }
17172 else
17173 {
17174 120 temp_mapscr->guytile = -1; //signal to use default guy values
17175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17177 }
17178
1/2
✓ Branch 0 taken 183534 times.
✗ Branch 1 not taken.
183534 if(!p_igetw(&(temp_mapscr->str),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 183534 times.
✗ Branch 1 not taken.
183534 if(!p_getc(&(temp_mapscr->room),f))
17181 return qe_invalid;
17182
1/2
✓ Branch 0 taken 183534 times.
✗ Branch 1 not taken.
183534 if(!p_igetw(&(temp_mapscr->catchall),f))
17183 return qe_invalid;
17184 183534 }
17185
2/2
✓ Branch 0 taken 189105 times.
✓ Branch 1 taken 4887 times.
193992 if(scr_has_flags & SCRHAS_ITEM)
17186 {
17187
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->item),f))
17188 return qe_invalid;
17189
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->hasitem),f))
17190 return qe_invalid;
17191
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->itemx),f))
17192 return qe_invalid;
17193
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->itemy),f))
17194 return qe_invalid;
17195 4887 }
17196
2/2
✓ Branch 0 taken 176066 times.
✓ Branch 1 taken 17926 times.
193992 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17197 {
17198
1/2
✓ Branch 0 taken 17926 times.
✗ Branch 1 not taken.
17926 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17199 return qe_invalid;
17200 17926 }
17201
2/2
✓ Branch 0 taken 186884 times.
✓ Branch 1 taken 7108 times.
193992 if(scr_has_flags & SCRHAS_TWARP)
17202 {
17203
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17204 {
17205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17206 return qe_invalid;
17207 28432 }
17208
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17209 {
17210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17211 return qe_invalid;
17212 28432 }
17213
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17214 {
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17216 return qe_invalid;
17217 28432 }
17218
1/2
✓ Branch 0 taken 7108 times.
✗ Branch 1 not taken.
7108 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17219 return qe_invalid;
17220 7108 }
17221
2/2
✓ Branch 0 taken 181762 times.
✓ Branch 1 taken 12230 times.
193992 if(scr_has_flags & SCRHAS_SWARP)
17222 {
17223
2/2
✓ Branch 0 taken 48920 times.
✓ Branch 1 taken 12230 times.
61150 for(int32_t i=0; i<4; i++)
17224 {
17225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48920 times.
48920 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17226 return qe_invalid;
17227 48920 }
17228
2/2
✓ Branch 0 taken 48920 times.
✓ Branch 1 taken 12230 times.
61150 for(int32_t i=0; i<4; i++)
17229 {
17230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48920 times.
48920 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17231 return qe_invalid;
17232 48920 }
17233
2/2
✓ Branch 0 taken 48920 times.
✓ Branch 1 taken 12230 times.
61150 for(int32_t i=0; i<4; i++)
17234 {
17235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48920 times.
48920 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17236 return qe_invalid;
17237 48920 }
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12230 times.
12230 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17239 return qe_invalid;
17240
1/2
✓ Branch 0 taken 12230 times.
✗ Branch 1 not taken.
12230 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17241 return qe_invalid;
17242 12230 }
17243
2/2
✓ Branch 0 taken 181162 times.
✓ Branch 1 taken 12830 times.
193992 if(scr_has_flags & SCRHAS_WARPRET)
17244 {
17245
2/2
✓ Branch 0 taken 51320 times.
✓ Branch 1 taken 12830 times.
64150 for(int32_t i=0; i<4; i++)
17246 {
17247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51320 times.
51320 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17248 return qe_invalid;
17249 51320 }
17250
2/2
✓ Branch 0 taken 51320 times.
✓ Branch 1 taken 12830 times.
64150 for(int32_t i=0; i<4; i++)
17251 {
17252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51320 times.
51320 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17253 return qe_invalid;
17254 51320 }
17255
1/2
✓ Branch 0 taken 12830 times.
✗ Branch 1 not taken.
12830 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17256 return qe_invalid;
17257
1/2
✓ Branch 0 taken 12830 times.
✗ Branch 1 not taken.
12830 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17258 return qe_invalid;
17259 12830 }
17260
2/2
✓ Branch 0 taken 165266 times.
✓ Branch 1 taken 28726 times.
193992 if(scr_has_flags & SCRHAS_LAYERS)
17261 {
17262
2/2
✓ Branch 0 taken 172356 times.
✓ Branch 1 taken 28726 times.
201082 for(int32_t k=0; k<6; k++)
17263 {
17264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172356 times.
172356 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17265 return qe_invalid;
17266 172356 }
17267
2/2
✓ Branch 0 taken 172356 times.
✓ Branch 1 taken 28726 times.
201082 for(int32_t k=0; k<6; k++)
17268 {
17269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172356 times.
172356 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17270 return qe_invalid;
17271 172356 }
17272
2/2
✓ Branch 0 taken 172356 times.
✓ Branch 1 taken 28726 times.
201082 for(int32_t k=0; k<6; k++)
17273 {
17274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172356 times.
172356 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17275 return qe_invalid;
17276 172356 }
17277
1/2
✓ Branch 0 taken 28726 times.
✗ Branch 1 not taken.
28726 if(!p_getc(&(temp_mapscr->hidelayers),f))
17278 return qe_invalid;
17279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28726 times.
28726 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17280 return qe_invalid;
17281 28726 }
17282
2/2
✓ Branch 0 taken 193888 times.
✓ Branch 1 taken 104 times.
193992 if(scr_has_flags & SCRHAS_MAZE)
17283 {
17284
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17285 {
17286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17287 return qe_invalid;
17288 416 }
17289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17290 return qe_invalid;
17291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17292 {
17293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17294 return qe_invalid;
17295 104 }
17296 104 }
17297
2/2
✓ Branch 0 taken 148265 times.
✓ Branch 1 taken 45727 times.
193992 if(scr_has_flags & SCRHAS_D_S_U)
17298 {
17299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148265 times.
148265 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17300 return qe_invalid;
17301
2/2
✓ Branch 0 taken 593060 times.
✓ Branch 1 taken 148265 times.
741325 for(int32_t k=0; k<4; k++)
17302 {
17303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593060 times.
593060 if(!p_getc(&(temp_mapscr->door[k]),f))
17304 return qe_invalid;
17305
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 592700 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
593060 if(version < 29 && temp_mapscr->door[k] == dNONE)
17306 temp_mapscr->door[k] = dWALL;
17307 593060 }
17308
17309
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_getc(&(temp_mapscr->stairx),f))
17310 return qe_invalid;
17311
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148265 times.
148265 if(!p_getc(&(temp_mapscr->stairy),f))
17313 return qe_invalid;
17314
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_igetw(&(temp_mapscr->undercombo),f))
17315 return qe_invalid;
17316
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_getc(&(temp_mapscr->undercset),f))
17317 return qe_invalid;
17318 148265 }
17319
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 35239 times.
45727 else if(version < 29)
17320 {
17321
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17322 41952 temp_mapscr->door[k] = dWALL;
17323 10488 }
17324
2/2
✓ Branch 0 taken 179031 times.
✓ Branch 1 taken 14961 times.
193992 if(scr_has_flags & SCRHAS_FLAGS)
17325 {
17326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14961 times.
14961 if(!p_getc(&(temp_mapscr->flags),f))
17327 return qe_invalid;
17328
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags2),f))
17329 return qe_invalid;
17330
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags3),f))
17331 return qe_invalid;
17332
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags4),f))
17333 return qe_invalid;
17334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14961 times.
14961 if(!p_getc(&(temp_mapscr->flags5),f))
17335 return qe_invalid;
17336
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags6),f))
17337 return qe_invalid;
17338
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags7),f))
17339 return qe_invalid;
17340
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags8),f))
17341 return qe_invalid;
17342
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags9),f))
17343 return qe_invalid;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14961 times.
14961 if(!p_getc(&(temp_mapscr->flags10),f))
17345 return qe_invalid;
17346
1/2
✓ Branch 0 taken 14961 times.
✗ Branch 1 not taken.
14961 if(!p_getc(&(temp_mapscr->flags11),f))
17347 return qe_invalid;
17348 14961 }
17349
2/2
✓ Branch 0 taken 180271 times.
✓ Branch 1 taken 13721 times.
193992 if(scr_has_flags & SCRHAS_ENEMY)
17350 {
17351
2/2
✓ Branch 0 taken 137210 times.
✓ Branch 1 taken 13721 times.
150931 for(int32_t k=0; k<10; k++)
17352 {
17353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137210 times.
137210 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17354 return qe_invalid;
17355
1/2
✓ Branch 0 taken 137210 times.
✗ Branch 1 not taken.
137210 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17356 temp_mapscr->enemy[k] = 0;
17357 137210 }
17358
1/2
✓ Branch 0 taken 13721 times.
✗ Branch 1 not taken.
13721 if(!p_getc(&(temp_mapscr->pattern),f))
17359 return qe_invalid;
17360 13721 }
17361
2/2
✓ Branch 0 taken 153821 times.
✓ Branch 1 taken 40171 times.
193992 if(scr_has_flags & SCRHAS_CARRY)
17362 {
17363
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 153483 times.
153821 if(version < 34)
17364 {
17365 word tmpw;
17366
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&tmpw,f))
17367 return qe_invalid;
17368 338 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17369
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&tmpw,f))
17370 return qe_invalid;
17371 676 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17372 338 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17373 338 }
17374 else
17375 {
17376
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->noreset),f))
17377 return qe_invalid;
17378
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->nocarry),f))
17379 return qe_invalid;
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153483 times.
153483 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17381 return qe_invalid;
17382
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17383 return qe_invalid;
17384 }
17385
1/2
✓ Branch 0 taken 153821 times.
✗ Branch 1 not taken.
153821 if(!p_getc(&(temp_mapscr->nextmap),f))
17386 return qe_invalid;
17387
1/2
✓ Branch 0 taken 153821 times.
✗ Branch 1 not taken.
153821 if(!p_getc(&(temp_mapscr->nextscr),f))
17388 return qe_invalid;
17389 153821 }
17390 else
17391 {
17392
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 39439 times.
40171 if(version < 34)
17393 {
17394 39439 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17395 39439 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17396 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17397 39439 }
17398 }
17399
2/2
✓ Branch 0 taken 193263 times.
✓ Branch 1 taken 729 times.
193992 if(scr_has_flags & SCRHAS_SCRIPT)
17400 {
17401
1/2
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
729 if(!p_igetw(&(temp_mapscr->script),f))
17402 return qe_invalid;
17403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if(!p_getc(&(temp_mapscr->preloadscript),f))
17404 return qe_invalid;
17405
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 729 times.
6561 for ( int32_t q = 0; q < 8; q++ )
17406 {
17407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5832 times.
5832 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17408 return qe_invalid;
17409 5832 }
17410 729 }
17411
2/2
✓ Branch 0 taken 154341 times.
✓ Branch 1 taken 39651 times.
193992 if(scr_has_flags & SCRHAS_SECRETS)
17412 {
17413
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17414 {
17415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17416 return qe_invalid;
17417 5075328 }
17418
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17419 {
17420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17421 return qe_invalid;
17422 5075328 }
17423
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17424 {
17425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17426 return qe_invalid;
17427 5075328 }
17428 39651 }
17429
2/2
✓ Branch 0 taken 74452 times.
✓ Branch 1 taken 119540 times.
193992 if(scr_has_flags & SCRHAS_COMBOFLAG)
17430 {
17431
2/2
✓ Branch 0 taken 21039040 times.
✓ Branch 1 taken 119540 times.
21158580 for(int32_t k=0; k<176; ++k)
17432 {
17433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21039040 times.
21039040 if(!p_igetw(&(temp_mapscr->data[k]),f))
17434 return qe_invalid;
17435 21039040 }
17436
2/2
✓ Branch 0 taken 21039040 times.
✓ Branch 1 taken 119540 times.
21158580 for(int32_t k=0; k<176; ++k)
17437 {
17438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21039040 times.
21039040 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17439 return qe_invalid;
17440 21039040 }
17441
2/2
✓ Branch 0 taken 21039040 times.
✓ Branch 1 taken 119540 times.
21158580 for(int32_t k=0; k<176; ++k)
17442 {
17443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21039040 times.
21039040 if(!p_getc(&(temp_mapscr->cset[k]),f))
17444 return qe_invalid;
17445 21039040 }
17446 119540 }
17447
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(scr_has_flags & SCRHAS_MISC)
17448 {
17449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193992 times.
193992 if(!p_igetw(&(temp_mapscr->color),f))
17450 return qe_invalid;
17451
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_getc(&(temp_mapscr->csensitive),f))
17452 return qe_invalid;
17453
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_getc(&(temp_mapscr->oceansfx),f))
17454 return qe_invalid;
17455
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_getc(&(temp_mapscr->bosssfx),f))
17456 return qe_invalid;
17457
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_getc(&(temp_mapscr->secretsfx),f))
17458 return qe_invalid;
17459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193992 times.
193992 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17460 return qe_invalid;
17461
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17462 return qe_invalid;
17463
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17464 return qe_invalid;
17465
1/2
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
193992 if(!p_getc(&(temp_mapscr->lens_layer),f))
17466 return qe_invalid;
17467
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 183414 times.
193992 if(version > 27)
17468 {
17469
1/2
✓ Branch 0 taken 183414 times.
✗ Branch 1 not taken.
183414 if(!p_getc(&(temp_mapscr->lens_show),f))
17470 return qe_invalid;
17471
1/2
✓ Branch 0 taken 183414 times.
✗ Branch 1 not taken.
183414 if(!p_getc(&(temp_mapscr->lens_hide),f))
17472 return qe_invalid;
17473 183414 }
17474 193992 }
17475 else
17476 {
17477 temp_mapscr->screen_midi = -1;
17478 temp_mapscr->csensitive = 1;
17479 }
17480 //FFC
17481 193992 bool old_ff = version < 25;
17482 193992 dword bits = 0;
17483 193992 word numffc = 32;
17484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193992 times.
193992 if(old_ff)
17485 {
17486 if(!p_igetl(&bits,f))
17487 return qe_invalid;
17488 }
17489 else
17490 {
17491
2/4
✓ Branch 0 taken 193992 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 193992 times.
193992 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17492 return qe_invalid;
17493 }
17494
17495 193992 temp_mapscr->ffcCountMarkDirty();
17496 193992 temp_mapscr->ffcs.clear();
17497 193992 temp_mapscr->resizeFFC(numffc);
17498
17499 byte tempbyte;
17500 word tempw;
17501
4/6
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 193816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 176 times.
✗ Branch 5 not taken.
193992 static ffcdata nil_ffc;
17502
2/2
✓ Branch 0 taken 1997090 times.
✓ Branch 1 taken 193992 times.
2191082 for(word m = 0; m < numffc; ++m)
17503 {
17504
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1997090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1997090 if(old_ff && !(bits & (1<<m))) continue;
17505
17506
1/2
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
1997090 ffcdata& tempffc = (m < MAXFFCS)
17507 1997090 ? temp_mapscr->ffcs[m]
17508 : nil_ffc; //sanity
17509
17510
1/2
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
1997090 if(!p_igetw(&tempw,f))
17511 return qe_invalid;
17512
3/4
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28170 times.
✓ Branch 3 taken 1968920 times.
1997090 if(!old_ff && !tempw) //empty ffc, nothing more to load
17513 1968920 continue;
17514 28170 tempffc.data = tempw;
17515
17516
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_getc(&(tempffc.cset),f))
17517 return qe_invalid;
17518
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetw(&(tempffc.delay),f))
17519 return qe_invalid;
17520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.x),f))
17521 return qe_invalid;
17522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.y),f))
17523 return qe_invalid;
17524
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.vx),f))
17525 return qe_invalid;
17526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.vy),f))
17527 return qe_invalid;
17528
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.ax),f))
17529 return qe_invalid;
17530
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.ay),f))
17531 return qe_invalid;
17532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_getc(&(tempffc.link),f))
17533 return qe_invalid;
17534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(version < 24)
17535 {
17536 if(!p_getc(&tempbyte,f))
17537 return qe_invalid;
17538 tempffc.hit_width = (tempbyte&0x3F)+1;
17539 tempffc.txsz = (tempbyte>>6)+1;
17540 if(!p_getc(&tempbyte,f))
17541 return qe_invalid;
17542 tempffc.hit_height = (tempbyte&0x3F)+1;
17543 tempffc.tysz = (tempbyte>>6)+1;
17544 }
17545 else
17546 {
17547
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.hit_width),f))
17548 return qe_invalid;
17549
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.hit_height),f))
17550 return qe_invalid;
17551
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_getc(&(tempffc.txsz),f))
17552 return qe_invalid;
17553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_getc(&(tempffc.tysz),f))
17554 return qe_invalid;
17555 }
17556
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.flags),f))
17557 return qe_invalid;
17558 28170 tempffc.updateSolid();
17559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetw(&(tempffc.script),f))
17560 return qe_invalid;
17561
2/2
✓ Branch 0 taken 225360 times.
✓ Branch 1 taken 28170 times.
253530 for(auto q = 0; q < 8; ++q)
17562 {
17563
1/2
✓ Branch 0 taken 225360 times.
✗ Branch 1 not taken.
225360 if(!p_igetl(&(tempffc.initd[q]),f))
17564 return qe_invalid;
17565 225360 }
17566
2/2
✓ Branch 0 taken 7792 times.
✓ Branch 1 taken 20378 times.
28170 if(version < 33)
17567 {
17568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7792 times.
7792 if(!p_getc(&(tempbyte),f))
17569 return qe_invalid;
17570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7792 times.
7792 if(!p_getc(&(tempbyte),f))
17571 return qe_invalid;
17572 7792 }
17573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20378 times.
20378 else if(!p_getc(&(tempffc.layer),f))
17574 return qe_invalid;
17575
17576
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17577 {
17578 tempffc.script = 0;
17579 for(int q = 0; q < 8; ++q)
17580 tempffc.initd[q] = 0;
17581 }
17582 28170 }
17583 //END FFC
17584
2/2
✓ Branch 0 taken 39375 times.
✓ Branch 1 taken 154617 times.
193992 if(version > 29)
17585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154617 times.
154617 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17586 return qe_invalid;
17587
17588
4/4
✓ Branch 0 taken 67935 times.
✓ Branch 1 taken 126057 times.
✓ Branch 2 taken 67833 times.
✓ Branch 3 taken 102 times.
193992 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17589 {
17590
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17591 return qe_invalid;
17592
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17593 return qe_invalid;
17594 102 }
17595 }
17596
17597 1372848 temp_mapscr->shrinkToFitFFCs();
17598
17599 1372848 return 0;
17600 1563056 }
17601
17602 498 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17603 {
17604
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17605 498 int32_t screen=0;
17606
17607 498 word version=0;
17608 dword dummy;
17609 int32_t screens_to_read;
17610
17611 498 mapscr temp_mapscr{};
17612 word temp_map_count;
17613 dword section_size;
17614
17615
5/6
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
498 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17616 {
17617 18 screens_to_read=MAPSCRS192b136;
17618 18 }
17619 else
17620 {
17621 480 screens_to_read=MAPSCRS;
17622 }
17623
17624
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 if(Header->zelda_version > 0x192)
17625 {
17626 //section version info
17627
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&version,f))
17628 {
17629 return qe_invalid;
17630 }
17631
17632
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (version > V_MAPS)
17633 return qe_version;
17634
17635 474 FFCore.quest_format[vMaps] = version;
17636
17637
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&dummy,f))
17638 {
17639 return qe_invalid;
17640 }
17641
17642 //section size
17643
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&section_size,f))
17644 {
17645 return qe_invalid;
17646 }
17647
17648 //finally... section data
17649
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&temp_map_count,f))
17650 {
17651 return 5;
17652 }
17653 474 }
17654 else
17655 {
17656 24 temp_map_count=map_count;
17657 }
17658
17659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
498 if (temp_map_count > MAXMAPS)
17660 {
17661 return qe_invalid;
17662 }
17663
17664
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
498 if (!should_skip)
17665 {
17666 497 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17667 497 TheMaps.clear();
17668
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 TheMaps.resize(_mapsSize);
17669 497 old_combo_pages.clear();
17670
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 old_combo_pages.resize(_mapsSize);
17671 497 map_infos.clear();
17672
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 map_infos.resize(temp_map_count);
17673
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 169 times.
497 if(version >= 31)
17674 169 Regions = {};
17675 497 }
17676
17677
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 12911 times.
✓ Branch 2 taken 12911 times.
✓ Branch 3 taken 498 times.
13409 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17678 {
17679 12911 byte valid=1;
17680
2/2
✓ Branch 0 taken 4238 times.
✓ Branch 1 taken 8673 times.
12911 if(version > 22)
17681 {
17682
2/4
✓ Branch 0 taken 4238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4238 times.
✗ Branch 3 not taken.
4238 if(!p_getc(&valid,f))
17683 return qe_invalid;
17684 4238 }
17685
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 11498 times.
12911 if(valid)
17686 {
17687
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 2695 times.
11498 if (version > 25)
17688 {
17689 2695 auto& mapinf = map_infos[i];
17690
2/2
✓ Branch 0 taken 16170 times.
✓ Branch 1 taken 2695 times.
18865 for(int q = 0; q < 6; ++q)
17691 {
17692
2/4
✓ Branch 0 taken 16170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16170 times.
✗ Branch 3 not taken.
16170 if(!p_igetw(&mapinf.autolayers[q],f))
17693 return qe_invalid;
17694 16170 }
17695
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 1747 times.
2695 if (version >= 36)
17696
2/4
✓ Branch 0 taken 948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
948 if(!p_igetw(&mapinf.autopalette,f))
17697 return qe_invalid;
17698 2695 }
17699
17700
2/2
✓ Branch 0 taken 9262 times.
✓ Branch 1 taken 2236 times.
11498 if (version >= 31)
17701 {
17702 static regions_data tmp_rd;
17703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2236 times.
2236 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17704
2/2
✓ Branch 0 taken 17888 times.
✓ Branch 1 taken 2236 times.
20124 for(int32_t j=0; j<8; j++)
17705 {
17706
2/2
✓ Branch 0 taken 143104 times.
✓ Branch 1 taken 17888 times.
160992 for(int32_t k=0; k<8; k++)
17707 {
17708
2/4
✓ Branch 0 taken 143104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143104 times.
✗ Branch 3 not taken.
143104 if(!p_getc(&rd.region_ids[j][k],f))
17709 {
17710 return qe_invalid;
17711 }
17712 143104 }
17713 17888 }
17714 2236 }
17715 11498 }
17716
2/2
✓ Branch 0 taken 1755224 times.
✓ Branch 1 taken 12911 times.
1768135 for(int32_t j=0; j<screens_to_read; j++)
17717 {
17718 1755224 screen=i*MAPSCRS+j;
17719
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1754952 times.
1755224 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17720 1755224 scr->map = i;
17721 1755224 scr->screen = j;
17722
2/2
✓ Branch 0 taken 1563056 times.
✓ Branch 1 taken 192168 times.
1755224 if(valid)
17723
1/2
✓ Branch 0 taken 1563056 times.
✗ Branch 1 not taken.
1563056 readmapscreen(f, Header, scr, version, screen);
17724
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 else if (!should_skip)
17725
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 clear_screen(scr);
17726 1755224 }
17727
17728
2/2
✓ Branch 0 taken 12909 times.
✓ Branch 1 taken 2 times.
12911 if (should_skip)
17729 2 continue;
17730
17731
5/6
✓ Branch 0 taken 12741 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12723 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12909 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17732 {
17733 168 int32_t index = (i*MAPSCRS+132);
17734
17735
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17736
17737 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17738 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17739 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17740
17741
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17742 {
17743 504 screen=i*MAPSCRS+j;
17744
17745
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17746 504 TheMaps[screen].valid = mVERSION;
17747 504 TheMaps[screen].screen_midi = -1;
17748 504 TheMaps[screen].csensitive = 1;
17749 504 }
17750 168 }
17751
17752
5/6
✓ Branch 0 taken 12741 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12723 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12909 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17753 {
17754
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17755 {
17756 22848 screen=i*MAPSCRS+j;
17757
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17758
17759
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17760 {
17761
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17762
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17763
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17764 2924544 }
17765 22848 }
17766 168 }
17767 12909 }
17768 498 map_count = temp_map_count;
17769 498 return 0;
17770 498 }
17771
17772
17773 9237807 void update_combo(newcombo& cmb, word section_version)
17774 {
17775
2/2
✓ Branch 0 taken 1555788 times.
✓ Branch 1 taken 7682019 times.
9237807 if(section_version < 40)
17776 {
17777
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17778 {
17779 case cWATER: case cSHALLOWWATER:
17780 45418 cmb.attribytes[6] = iwRipples;
17781 45418 break;
17782 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17783 5144 cmb.attribytes[6] = iwTallGrass;
17784 5144 break;
17785 }
17786 7682019 }
17787
2/2
✓ Branch 0 taken 1205450 times.
✓ Branch 1 taken 8032357 times.
9237807 if(section_version < 49)
17788 {
17789
4/4
✓ Branch 0 taken 7997549 times.
✓ Branch 1 taken 34808 times.
✓ Branch 2 taken 15487 times.
✓ Branch 3 taken 7982062 times.
8032357 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17790 50295 cmb.sfx_landing = WAV_ZN1SPLASH;
17791 8032357 }
17792 9237807 }
17793 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17794 {
17795
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17796 byte tempbyte;
17797
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17798 {
17799 287 reset_all_combo_animations();
17800 287 init_combo_classes();
17801 287 }
17802
17803 // combos
17804 288 word combos_used=0;
17805 int32_t dummy;
17806 byte padding;
17807 288 newcombo temp_combo;
17808
17809
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17810
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17811
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17812
17813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17814 {
17815 combos_used=1024;
17816 }
17817
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17818 {
17819 18 combos_used=2048;
17820 18 }
17821 else
17822 {
17823
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17824 {
17825 return qe_invalid;
17826 }
17827 }
17828
17829 //finally... section data
17830
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17831 {
17832
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17833
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17834 7547003 int32_t temp_trigflags[6] = {0};
17835
17836
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17837 {
17838
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17839 {
17840 return qe_invalid;
17841 }
17842 202968 }
17843 else
17844 {
17845
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17846 {
17847 return qe_invalid;
17848 }
17849 }
17850 7547003 temp_combo.o_tile = temp_combo.tile;
17851
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17852 {
17853 return qe_invalid;
17854 }
17855
17856
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17857 {
17858 return qe_invalid;
17859 }
17860
17861
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17862 {
17863 return qe_invalid;
17864 }
17865
17866
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17867 {
17868 return qe_invalid;
17869 }
17870
17871
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17872 {
17873
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17874 return qe_invalid;
17875
17876
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17877 return qe_invalid;
17878
17879
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17880 {
17881
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17882 {
17883 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17884 {
17885 if(!p_getc(&padding,f))
17886 return qe_invalid;
17887 }
17888 }
17889 36864 }
17890 69774 }
17891
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17892 {
17893
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17894 return qe_invalid;
17895
17896
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17897 return qe_invalid;
17898
17899
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17900 return qe_invalid;
17901
17902
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17903 return qe_invalid;
17904
17905 //Base flag
17906
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17907
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17908 return qe_invalid;
17909
17910
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17911 {
17912
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17913 return qe_invalid;
17914
17915
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17916 return qe_invalid;
17917 4621731 }
17918
17919
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17920
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17921 return qe_invalid;
17922
17923
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17924 {
17925
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17926 return qe_invalid;
17927
17928
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17929 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17930 4621731 }
17931
17932
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17933 {
17934
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17935
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17936 return qe_invalid;
17937
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17938 return qe_invalid;
17939
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17940
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17941 return qe_invalid;
17942 202968 }
17943
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17944 {
17945
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17946
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17947 return qe_invalid;
17948 202968 }
17949
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17950 {
17951 for ( int32_t q = 0; q < 2; q++ )
17952 if(!p_igetl(&temp_trigflags[q],f))
17953 return qe_invalid;
17954 }
17955
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17956
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17957 return qe_invalid;
17958
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17959
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17960 return qe_invalid;
17961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17962 {
17963 if(!p_getc(&temp_trigger.triggeritem,f))
17964 return qe_invalid;
17965 if(!p_getc(&tempbyte, f))
17966 return qe_invalid;
17967 temp_trigger.trigtimer = tempbyte;
17968 }
17969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17970 if(!p_getc(&temp_trigger.trigsfx,f))
17971 return qe_invalid;
17972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17973 if(!p_igetl(&temp_trigger.trigchange,f))
17974 return qe_invalid;
17975
17976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17977 {
17978 if(!p_igetw(&temp_trigger.trigprox,f))
17979 return qe_invalid;
17980 if(!p_getc(&tempbyte,f))
17981 return qe_invalid;
17982 temp_trigger.trigctr = tempbyte;
17983 if(!p_igetl(&temp_trigger.trigctramnt,f))
17984 return qe_invalid;
17985 }
17986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17987 if(!p_getc(&temp_trigger.triglbeam,f))
17988 return qe_invalid;
17989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17990 {
17991 if(!p_getc(&temp_trigger.trigcschange,f))
17992 return qe_invalid;
17993 if(!p_igetw(&temp_trigger.spawnitem,f))
17994 return qe_invalid;
17995 if(!p_igetw(&temp_trigger.spawnenemy,f))
17996 return qe_invalid;
17997 if(!p_getc(&temp_trigger.exstate,f))
17998 return qe_invalid;
17999 if(!p_igetl(&temp_trigger.spawnip,f))
18000 return qe_invalid;
18001 if(!p_getc(&temp_trigger.trigcopycat,f))
18002 return qe_invalid;
18003 }
18004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
18005 if(!p_getc(&temp_trigger.trigcooldown,f))
18006 return qe_invalid;
18007
18008
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
18009 {
18010 char label[12];
18011 202968 label[11] = '\0';
18012
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
18013
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
18014 return qe_invalid;
18015
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
18016 202968 }
18017
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=13) //attribytes[4]
18018
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
18019
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
18020 202968 return qe_invalid;
18021 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
18022 * This fixes a poor implementation of a ->next flag bug thing.
18023 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
18024 * there was a version bump a few weeks before a change that broke stuff.
18025 */
18026
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
18027 {
18028 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
18029 }
18030 //combo scripts
18031
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
18032 {
18033
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
18034 return qe_invalid;
18035
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
18036
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
18037 return qe_invalid;
18038 202968 }
18039
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
18040 {
18041
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
18042
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
18043
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
18044
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
18045 202968 }
18046
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=17) //attribytes[4]
18047 {
18048
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18049
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
18050 return qe_invalid;
18051
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18052
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
18053 return qe_invalid;
18054 202968 }
18055
18056
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
18057
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
18058
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
18059 32910 return qe_invalid;
18060 7510139 }
18061
18062 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18063
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
18064 {
18065
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
18066 {
18067
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
18068 {
18069 case 130:
18070 temp_combo.tile = 132;
18071 break;
18072
18073 case 131:
18074 temp_combo.tile = 133;
18075 break;
18076
18077 case 132:
18078 temp_combo.tile = 130;
18079 break;
18080
18081 case 133:
18082 temp_combo.tile = 131;
18083 break;
18084 }
18085 39936 }
18086 2925272 }
18087
18088
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
18089 7344035 temp_combo.o_tile = temp_combo.tile;
18090
18091
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
18092 7344035 temp_combo.walk |= 0xF0;
18093
18094
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
18095
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
18096 36720175 temp_combo.attributes[q] *= 10000L;
18097
18098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
18099 {
18100
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
18101 {
18102 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18103 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18104 case cTRIGGERGENERIC: case cCSWITCH:
18105 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
18106 15235 }
18107 7547003 }
18108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
18109 {
18110
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
18111 {
18112 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27396 times.
27396 if(!(temp_combo.usrflags & cflag3))
18114 27396 temp_combo.attribytes[3] = WAV_DOOR;
18115 27396 temp_combo.usrflags &= ~cflag3;
18116 27396 break;
18117 }
18118 7547003 }
18119
18120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
18121
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
18122
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
18123 temp_combo.usrflags |= cflag3;
18124
18125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
18126 {
18127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
18128 temp_trigger.trigchange = 1;
18129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
18130 temp_trigger.trigchange = -1;
18131 7547003 else temp_trigger.trigchange = 0;
18132 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
18133 7547003 }
18134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 28)
18135 {
18136
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
18137 {
18138 case cLOCKBLOCK: case cLOCKEDCHEST:
18139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
18140 temp_combo.usrflags |= cflag8;
18141 15512 else temp_combo.usrflags &= ~cflag8;
18142 15512 temp_combo.usrflags &= ~cflag7;
18143 15512 break;
18144 }
18145
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
18146 {
18147 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18148 758 temp_combo.attrishorts[2] = -1;
18149 758 temp_combo.usrflags |= cflag7;
18150 758 break;
18151 }
18152 7547003 }
18153
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
18154 {
18155 7344035 temp_combo.genflags = 0;
18156
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
18157 {
18158 case cPUSH_WAIT: case cPUSH_HEAVY:
18159 case cPUSH_HW: case cL_STATUE:
18160 case cR_STATUE: case cPUSH_HEAVY2:
18161 case cPUSH_HW2: case cPOUND:
18162 case cC_STATUE: case cMIRROR:
18163 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18164 case cMAGICPRISM: case cMAGICPRISM4:
18165 case cMAGICSPONGE: case cEYEBALL_A:
18166 case cEYEBALL_B: case cEYEBALL_4:
18167 case cBUSH: case cFLOWERS:
18168 case cLOCKBLOCK: case cLOCKBLOCK2:
18169 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18170 case cCHEST: case cCHEST2:
18171 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18172 case cBOSSCHEST: case cBOSSCHEST2:
18173 case cBUSHNEXT: case cBUSHTOUCHY:
18174 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18175 case cSIGNPOST: case cCSWITCHBLOCK:
18176 case cTORCH: case cTRIGGERGENERIC:
18177
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
18178 {
18179 temp_combo.genflags |= cflag1;
18180 temp_combo.usrflags &= ~cflag16;
18181 }
18182 143987 break;
18183 }
18184 7344035 }
18185
18186
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18187
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18188 {
18189 1449024576 auto ind = q/32;
18190 1449024576 auto bit = 1<<(q%32);
18191
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18192
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18193 1449024576 }
18194
18195
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18196 7531729 temp_combo.triggers.clear();
18197
18198 7547003 update_combo(temp_combo, section_version);
18199
18200
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18201 {
18202
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18203 {
18204 temp_combo.script = 0;
18205 for(int q = 0; q < 8; ++q)
18206 temp_combo.initd[q] = 0;
18207 }
18208
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18209 7532084 }
18210 7547003 }
18211
18212
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18213 1 return 0;
18214
18215
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18216 {
18217
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18218 {
18219
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18220 {
18221 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18222 215 }
18223 1501440 }
18224 23 }
18225
18226 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18227
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18228 {
18229
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18230
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18231 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18232 59 }
18233
18234
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18235 {
18236
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18237 {
18238
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18239 {
18240 case cSLASH:
18241 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18242 853 break;
18243
18244 case cSLASHITEM:
18245 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18246 791 break;
18247
18248 case cBUSH:
18249 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18250 603 break;
18251
18252 case cFLOWERS:
18253 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18254 174 break;
18255
18256 case cTALLGRASS:
18257 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18258 531 break;
18259
18260 case cSLASHNEXT:
18261 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18262 break;
18263
18264 case cSLASHNEXTITEM:
18265 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18266 break;
18267
18268 case cBUSHNEXT:
18269 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18270 break;
18271 }
18272 5352960 }
18273 82 }
18274
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18275 {
18276
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18277 {
18278
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18279 {
18280 28841 combobuf[tmpcounter].attributes[0] = 40000L;
18281 28841 }
18282 18408960 }
18283 282 }
18284
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18285 {
18286 3 combobuf[0].walk = 0xF0;
18287 3 combobuf[0].type = 0;
18288 3 combobuf[0].flag = 0;
18289 3 }
18290
18291 //Now for the new combo alias reset
18292
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18293 {
18294
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18295 {
18296 671744 combo_aliases[j].width = 0;
18297 671744 combo_aliases[j].height = 0;
18298 671744 combo_aliases[j].layermask = 0;
18299
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18300
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18301 671744 }
18302 82 }
18303
18304
18305
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18306
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18307 287 return 0;
18308 288 }
18309
18310 16673 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18311 {
18312 byte tempbyte;
18313
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9140 times.
16673 if(s_version >= 52)
18314
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_getcstr(&temp_trigger.label,f))
18315 return qe_invalid;
18316
18317
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8894 times.
16673 if(s_version < 57)
18318 {
18319 7779 int32_t temp_trigflags[6] = {0};
18320 7779 int numtrigs = s_version < 36 ? 3 : 6;
18321
2/2
✓ Branch 0 taken 45816 times.
✓ Branch 1 taken 7779 times.
53595 for ( int32_t q = 0; q < numtrigs; q++ )
18322
1/2
✓ Branch 0 taken 45816 times.
✗ Branch 1 not taken.
45816 if(!p_igetl(&temp_trigflags[q],f))
18323 return qe_invalid;
18324 7779 temp_trigger.trigger_flags.clear();
18325
2/2
✓ Branch 0 taken 1466112 times.
✓ Branch 1 taken 7779 times.
1473891 for(size_t q = 0; q < 32*numtrigs; ++q)
18326 {
18327 1466112 auto ind = q/32;
18328 1466112 auto bit = 1<<(q%32);
18329
2/2
✓ Branch 0 taken 1452438 times.
✓ Branch 1 taken 13674 times.
1466112 if(temp_trigflags[ind] & bit)
18330 13674 temp_trigger.trigger_flags.set(q, true);
18331 1466112 }
18332 7779 }
18333
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18334 return qe_invalid;
18335
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetl(&temp_trigger.triggerlevel,f))
18336 return qe_invalid;
18337
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.triggerbtn,f))
18338 return qe_invalid;
18339
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.triggeritem,f))
18340 return qe_invalid;
18341
2/2
✓ Branch 0 taken 9140 times.
✓ Branch 1 taken 7533 times.
16673 if(s_version >= 53)
18342 {
18343
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigtimer,f))
18344 return qe_invalid;
18345 9140 }
18346 else
18347 {
18348
1/2
✓ Branch 0 taken 7533 times.
✗ Branch 1 not taken.
7533 if(!p_getc(&tempbyte, f))
18349 return qe_invalid;
18350 7533 temp_trigger.trigtimer = tempbyte;
18351 }
18352
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.trigsfx,f))
18353 return qe_invalid;
18354
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetl(&temp_trigger.trigchange,f))
18355 return qe_invalid;
18356
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.trigprox,f))
18357 return qe_invalid;
18358
2/2
✓ Branch 0 taken 9140 times.
✓ Branch 1 taken 7533 times.
16673 if(s_version >= 53)
18359 {
18360
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigctr,f))
18361 return qe_invalid;
18362 9140 }
18363 else
18364 {
18365
1/2
✓ Branch 0 taken 7533 times.
✗ Branch 1 not taken.
7533 if(!p_getc(&tempbyte,f))
18366 return qe_invalid;
18367 7533 temp_trigger.trigctr = tempbyte;
18368 }
18369
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetl(&temp_trigger.trigctramnt,f))
18370 return qe_invalid;
18371
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.triglbeam,f))
18372 return qe_invalid;
18373
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.trigcschange,f))
18374 return qe_invalid;
18375
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.spawnitem,f))
18376 return qe_invalid;
18377
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.spawnenemy,f))
18378 return qe_invalid;
18379
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.exstate,f))
18380 return qe_invalid;
18381
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetl(&temp_trigger.spawnip,f))
18382 return qe_invalid;
18383
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.trigcopycat,f))
18384 return qe_invalid;
18385
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.trigcooldown,f))
18386 return qe_invalid;
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16673 times.
16673 if(s_version >= 35)
18388 {
18389
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.prompt_cid,f))
18390 return qe_invalid;
18391
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_getc(&temp_trigger.prompt_cs,f))
18392 return qe_invalid;
18393
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.prompt_x,f))
18394 return qe_invalid;
18395
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(!p_igetw(&temp_trigger.prompt_y,f))
18396 return qe_invalid;
18397 16673 }
18398
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16387 times.
16673 if(s_version >= 36)
18399 {
18400
1/2
✓ Branch 0 taken 16387 times.
✗ Branch 1 not taken.
16387 if(!p_getc(&temp_trigger.trig_lstate,f))
18401 return qe_invalid;
18402
1/2
✓ Branch 0 taken 16387 times.
✗ Branch 1 not taken.
16387 if(!p_getc(&temp_trigger.trig_gstate,f))
18403 return qe_invalid;
18404
1/2
✓ Branch 0 taken 16387 times.
✗ Branch 1 not taken.
16387 if(!p_igetl(&temp_trigger.trig_statetime,f))
18405 return qe_invalid;
18406 16387 }
18407
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16387 times.
16673 if(s_version >= 37)
18408 {
18409
1/2
✓ Branch 0 taken 16387 times.
✗ Branch 1 not taken.
16387 if(!p_igetw(&temp_trigger.trig_genscr,f))
18410 return qe_invalid;
18411 16387 }
18412
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 16239 times.
16673 if(s_version >= 38)
18413 {
18414
1/2
✓ Branch 0 taken 16239 times.
✗ Branch 1 not taken.
16239 if(!p_getc(&temp_trigger.trig_group,f))
18415 return qe_invalid;
18416
1/2
✓ Branch 0 taken 16239 times.
✗ Branch 1 not taken.
16239 if(!p_igetw(&temp_trigger.trig_group_val,f))
18417 return qe_invalid;
18418 16239 }
18419
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 16203 times.
16673 if(s_version >= 45)
18420 {
18421
1/2
✓ Branch 0 taken 16203 times.
✗ Branch 1 not taken.
16203 if(!p_getc(&temp_trigger.exdoor_dir,f))
18422 return qe_invalid;
18423
1/2
✓ Branch 0 taken 16203 times.
✗ Branch 1 not taken.
16203 if(!p_getc(&temp_trigger.exdoor_ind,f))
18424 return qe_invalid;
18425 16203 }
18426
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9140 times.
16673 if(s_version >= 46)
18427 {
18428
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 3306 times.
9140 if (s_version >= 59)
18429 {
18430
1/2
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
5834 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18431 return qe_invalid;
18432 5834 }
18433 else
18434 {
18435
1/2
✓ Branch 0 taken 3306 times.
✗ Branch 1 not taken.
3306 if(!p_getc(&tempbyte,f))
18436 return qe_invalid;
18437 3306 temp_trigger.trig_levelitems = word(tempbyte);
18438 }
18439
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18440 return qe_invalid;
18441
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(s_version >= 48)
18442 {
18443
2/2
✓ Branch 0 taken 27420 times.
✓ Branch 1 taken 9140 times.
36560 for(int q = 0; q < 3; ++q)
18444
1/2
✓ Branch 0 taken 27420 times.
✗ Branch 1 not taken.
27420 if(!p_igetw(&temp_trigger.trigtint[q],f))
18445 return qe_invalid;
18446 9140 }
18447 else
18448 {
18449 for(int q = 0; q < 3; ++q)
18450 if(!p_getc(&temp_trigger.trigtint[q],f))
18451 return qe_invalid;
18452 for(int q = 0; q < 3; ++q)
18453 {
18454 int v = temp_trigger.trigtint[q];
18455 int va = abs(v);
18456 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18457 }
18458 }
18459
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18460 return qe_invalid;
18461
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18462 return qe_invalid;
18463
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigquaketime,f))
18464 return qe_invalid;
18465
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trigwavytime,f))
18466 return qe_invalid;
18467
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18468 return qe_invalid;
18469
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18470 return qe_invalid;
18471
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18472 return qe_invalid;
18473
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18474 return qe_invalid;
18475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9140 times.
9140 if(!p_getc(&temp_trigger.trig_pushtime,f))
18476 return qe_invalid;
18477 9140 }
18478
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9140 times.
16673 if(s_version >= 47)
18479 {
18480
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18481 return qe_invalid;
18482 9140 }
18483
2/2
✓ Branch 0 taken 9140 times.
✓ Branch 1 taken 7533 times.
16673 if(s_version >= 53)
18484 {
18485
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetl(&temp_trigger.req_level_state, f))
18486 return qe_invalid;
18487
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18488 return qe_invalid;
18489
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18492 return qe_invalid;
18493
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18494 return qe_invalid;
18495
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18496 return qe_invalid;
18497
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18498 return qe_invalid;
18499
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18500 return qe_invalid;
18501
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetzf(&temp_trigger.player_bounce, f))
18502 return qe_invalid;
18503
1/2
✓ Branch 0 taken 9140 times.
✗ Branch 1 not taken.
9140 if(!p_igetzf(&temp_trigger.req_player_z, f))
18504 return qe_invalid;
18505 9140 }
18506 else
18507 {
18508 7533 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18509 7533 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18510 }
18511
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8894 times.
16673 if(s_version >= 54)
18512 {
18513
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_getc(&temp_trigger.req_player_dir,f))
18514 return qe_invalid;
18515
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18516 return qe_invalid;
18517
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18518 return qe_invalid;
18519
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18520 return qe_invalid;
18521
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18522 return qe_invalid;
18523
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.req_player_x, f))
18524 return qe_invalid;
18525
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.req_player_y, f))
18526 return qe_invalid;
18527 8894 }
18528
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8894 times.
16673 if(s_version >= 56)
18529 {
18530
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_getc(&temp_trigger.dest_player_dir, f))
18531 return qe_invalid;
18532
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18533 return qe_invalid;
18534
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18535 return qe_invalid;
18536
1/2
✓ Branch 0 taken 8894 times.
✗ Branch 1 not taken.
8894 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18537 return qe_invalid;
18538 8894 }
18539
2/2
✓ Branch 0 taken 10839 times.
✓ Branch 1 taken 5834 times.
16673 if(s_version >= 58)
18540 {
18541
1/2
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
5834 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18542 return qe_invalid;
18543
1/2
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
5834 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18544 return qe_invalid;
18545 5834 }
18546
2/2
✓ Branch 0 taken 11351 times.
✓ Branch 1 taken 5322 times.
16673 if (s_version >= 61)
18547 {
18548
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getbitstr(&temp_trigger.req_screen_state, f))
18549 return qe_invalid;
18550
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getbitstr(&temp_trigger.unreq_screen_state, f))
18551 return qe_invalid;
18552
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getbitstr(&temp_trigger.req_screen_ex_state, f))
18553 return qe_invalid;
18554
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getbitstr(&temp_trigger.unreq_screen_ex_state, f))
18555 return qe_invalid;
18556
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getc(&temp_trigger.trigstatemap, f))
18557 return qe_invalid;
18558
1/2
✓ Branch 0 taken 5322 times.
✗ Branch 1 not taken.
5322 if(!p_getc(&temp_trigger.trigstatescreen, f))
18559 return qe_invalid;
18560 5322 }
18561 16673 return 0;
18562 16673 }
18563
18564 1690804 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18565 {
18566 byte tempbyte;
18567 word combo_has_flags;
18568
2/2
✓ Branch 0 taken 516098 times.
✓ Branch 1 taken 1174706 times.
1690804 if(s_version < 55)
18569 {
18570
1/2
✓ Branch 0 taken 516098 times.
✗ Branch 1 not taken.
516098 if(!p_getc(&tempbyte,f))
18571 return qe_invalid;
18572 516098 combo_has_flags = tempbyte;
18573 516098 }
18574 else
18575 {
18576
1/2
✓ Branch 0 taken 1174706 times.
✗ Branch 1 not taken.
1174706 if(!p_igetw(&combo_has_flags,f))
18577 return qe_invalid;
18578 }
18579
18580 1690804 temp_combo.clear();
18581
2/2
✓ Branch 0 taken 291243 times.
✓ Branch 1 taken 1399561 times.
1690804 if(combo_has_flags)
18582 {
18583
2/2
✓ Branch 0 taken 608610 times.
✓ Branch 1 taken 790951 times.
1399561 if(combo_has_flags&CHAS_BASIC)
18584 {
18585
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_igetl(&temp_combo.tile,f))
18586 return qe_invalid;
18587 790951 temp_combo.o_tile = temp_combo.tile;
18588
18589
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_getc(&temp_combo.flip,f))
18590 return qe_invalid;
18591
18592
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_getc(&temp_combo.walk,f))
18593 return qe_invalid;
18594
18595
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_getc(&temp_combo.type,f))
18596 return qe_invalid;
18597
18598
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_getc(&temp_combo.flag,f))
18599 return qe_invalid;
18600
18601
1/2
✓ Branch 0 taken 790951 times.
✗ Branch 1 not taken.
790951 if(!p_getc(&temp_combo.csets,f))
18602 return qe_invalid;
18603 790951 }
18604
2/2
✓ Branch 0 taken 1396018 times.
✓ Branch 1 taken 3543 times.
1399561 if(combo_has_flags&CHAS_SCRIPT)
18605 {
18606
2/2
✓ Branch 0 taken 3513 times.
✓ Branch 1 taken 30 times.
3543 if (s_version>=41)
18607 {
18608 3513 p_getcstr(&temp_combo.label, f);
18609 3513 }
18610 else
18611 {
18612 char label[12];
18613 30 label[11] = '\0';
18614
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18615
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18616 return qe_invalid;
18617 30 temp_combo.label = label;
18618 }
18619
18620
1/2
✓ Branch 0 taken 3543 times.
✗ Branch 1 not taken.
3543 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18621 3543 auto initd_count = s_version >= 43 ? 8 : 2;
18622
2/2
✓ Branch 0 taken 28164 times.
✓ Branch 1 taken 3543 times.
31707 for ( int32_t q = 0; q < initd_count; q++ )
18623
1/2
✓ Branch 0 taken 28164 times.
✗ Branch 1 not taken.
28164 if(!p_igetl(&temp_combo.initd[q],f))
18624 return qe_invalid;
18625 3543 }
18626
2/2
✓ Branch 0 taken 1214152 times.
✓ Branch 1 taken 185409 times.
1399561 if(combo_has_flags&CHAS_ANIM)
18627 {
18628
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.frames,f))
18629 return qe_invalid;
18630
18631
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.speed,f))
18632 return qe_invalid;
18633
18634
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_igetw(&temp_combo.nextcombo,f))
18635 return qe_invalid;
18636
18637
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.nextcset,f))
18638 return qe_invalid;
18639
18640
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.skipanim,f))
18641 return qe_invalid;
18642
18643
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.skipanimy,f))
18644 return qe_invalid;
18645
18646
1/2
✓ Branch 0 taken 185409 times.
✗ Branch 1 not taken.
185409 if(!p_getc(&temp_combo.animflags,f))
18647 return qe_invalid;
18648 185409 }
18649
2/2
✓ Branch 0 taken 1333753 times.
✓ Branch 1 taken 65808 times.
1399561 if(combo_has_flags&CHAS_ATTRIB)
18650 {
18651
2/2
✓ Branch 0 taken 263232 times.
✓ Branch 1 taken 65808 times.
329040 for ( int32_t q = 0; q < 4; q++ )
18652
1/2
✓ Branch 0 taken 263232 times.
✗ Branch 1 not taken.
263232 if(!p_igetl(&temp_combo.attributes[q],f))
18653 return qe_invalid;
18654
2/2
✓ Branch 0 taken 526464 times.
✓ Branch 1 taken 65808 times.
592272 for ( int32_t q = 0; q < 8; q++ )
18655
1/2
✓ Branch 0 taken 526464 times.
✗ Branch 1 not taken.
526464 if(!p_getc(&temp_combo.attribytes[q],f))
18656 return qe_invalid;
18657
2/2
✓ Branch 0 taken 526464 times.
✓ Branch 1 taken 65808 times.
592272 for ( int32_t q = 0; q < 8; q++ )
18658
1/2
✓ Branch 0 taken 526464 times.
✗ Branch 1 not taken.
526464 if(!p_igetw(&temp_combo.attrishorts[q],f))
18659 return qe_invalid;
18660 65808 }
18661
2/2
✓ Branch 0 taken 1383231 times.
✓ Branch 1 taken 16330 times.
1399561 if(combo_has_flags&CHAS_FLAG)
18662 {
18663
1/2
✓ Branch 0 taken 16330 times.
✗ Branch 1 not taken.
16330 if(!p_igetl(&temp_combo.usrflags,f))
18664 return qe_invalid;
18665
1/2
✓ Branch 0 taken 16330 times.
✗ Branch 1 not taken.
16330 if(!p_igetw(&temp_combo.genflags,f))
18666 return qe_invalid;
18667 16330 }
18668
2/2
✓ Branch 0 taken 1382987 times.
✓ Branch 1 taken 16574 times.
1399561 if(combo_has_flags&CHAS_TRIG)
18669 {
18670 16574 byte count = 1;
18671
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9041 times.
16574 if(s_version >= 52)
18672
1/2
✓ Branch 0 taken 9041 times.
✗ Branch 1 not taken.
9041 if(!p_getc(&count, f))
18673 return qe_invalid;
18674
18675
2/2
✓ Branch 0 taken 16673 times.
✓ Branch 1 taken 16574 times.
33247 for(byte q = 0; q < count; ++q)
18676 {
18677 16673 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18678 16673 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18679
1/2
✓ Branch 0 taken 16673 times.
✗ Branch 1 not taken.
16673 if(ret)
18680 return ret;
18681 16673 }
18682
18683
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9041 times.
16574 if(s_version < 52)
18684 {
18685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7533 times.
7533 if(!temp_combo.triggers.empty())
18686 7533 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18687 7533 }
18688
1/2
✓ Branch 0 taken 9041 times.
✗ Branch 1 not taken.
9041 else if(!p_getc(&temp_combo.only_gentrig,f))
18689 return qe_invalid;
18690 16574 }
18691
2/2
✓ Branch 0 taken 224729 times.
✓ Branch 1 taken 1174832 times.
1399561 if(combo_has_flags&CHAS_LIFT)
18692 {
18693
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftcmb,f))
18694 return qe_invalid;
18695
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftcs,f))
18696 return qe_invalid;
18697
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftundercmb,f))
18698 return qe_invalid;
18699
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftundercs,f))
18700 return qe_invalid;
18701
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftdmg,f))
18702 return qe_invalid;
18703
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftlvl,f))
18704 return qe_invalid;
18705
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftitm,f))
18706 return qe_invalid;
18707
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftflags,f))
18708 return qe_invalid;
18709
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftgfx,f))
18710 return qe_invalid;
18711
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftsprite,f))
18712 return qe_invalid;
18713
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftsfx,f))
18714 return qe_invalid;
18715
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18716 return qe_invalid;
18717
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftbreaksfx,f))
18718 return qe_invalid;
18719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174832 times.
1174832 if(s_version >= 34)
18720 {
18721
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.lifthei,f))
18722 return qe_invalid;
18723
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.lifttime,f))
18724 return qe_invalid;
18725 1174832 }
18726
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1174818 times.
1174832 if(s_version >= 39)
18727 {
18728
1/2
✓ Branch 0 taken 1174818 times.
✗ Branch 1 not taken.
1174818 if(!p_getc(&temp_combo.lift_parent_item,f))
18729 return qe_invalid;
18730 1174818 }
18731 1174832 auto& weap_data = temp_combo.lift_weap_data;
18732
4/4
✓ Branch 0 taken 1174730 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 1174706 times.
✓ Branch 3 taken 24 times.
1174832 if(s_version >= 51 && s_version < 55)
18733 {
18734
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18735 return qe_invalid;
18736
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18737 return qe_invalid;
18738 24 }
18739
18740
2/2
✓ Branch 0 taken 1174706 times.
✓ Branch 1 taken 126 times.
1174832 if(s_version >= 55)
18741 {
18742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174706 times.
1174706 if(auto ret = read_weap_data(weap_data, f))
18743 return ret;
18744 1174706 }
18745 else
18746 {
18747 126 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18748 126 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18749
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 120 times.
126 switch(pitm.type)
18750 {
18751 case itype_bomb:
18752 case itype_sbomb:
18753 6 weap_data = pitm.weap_data;
18754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18755 {
18756 6 weap_data.flags |= wdata_glow_rad;
18757 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18758 6 }
18759 6 break;
18760 default:
18761 120 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18762 120 weap_data.flags |= wdata_glow_rad;
18763 120 }
18764 126 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18765
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 66 times.
126 if(temp_combo.liftflags & LF_BREAKONSOLID)
18766 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18767 }
18768 1174832 }
18769
18770
2/2
✓ Branch 0 taken 1362941 times.
✓ Branch 1 taken 36620 times.
1399561 if(combo_has_flags&CHAS_GENERAL)
18771 {
18772
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.speed_mult,f))
18773 return qe_invalid;
18774
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.speed_div,f))
18775 return qe_invalid;
18776
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_igetzf(&temp_combo.speed_add,f))
18777 return qe_invalid;
18778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36620 times.
36620 if(s_version >= 42)
18779 {
18780
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_appear,f))
18781 return qe_invalid;
18782
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_disappear,f))
18783 return qe_invalid;
18784
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_loop,f))
18785 return qe_invalid;
18786
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_walking,f))
18787 return qe_invalid;
18788
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_standing,f))
18789 return qe_invalid;
18790
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_appear,f))
18791 return qe_invalid;
18792
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_disappear,f))
18793 return qe_invalid;
18794
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_walking,f))
18795 return qe_invalid;
18796
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_standing,f))
18797 return qe_invalid;
18798 36620 }
18799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36620 times.
36620 if(s_version >= 44)
18800 {
18801
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_tap,f))
18802 return qe_invalid;
18803 36620 }
18804
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 36236 times.
36620 if(s_version >= 49)
18805 {
18806
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_landing,f))
18807 return qe_invalid;
18808 36236 }
18809
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 36236 times.
36620 if(s_version >= 50)
18810 {
18811
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_falling,f))
18812 return qe_invalid;
18813
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_drowning,f))
18814 return qe_invalid;
18815
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18816 return qe_invalid;
18817
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_falling,f))
18818 return qe_invalid;
18819
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_drowning,f))
18820 return qe_invalid;
18821
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18822 return qe_invalid;
18823 36236 }
18824
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 34742 times.
36620 if(s_version >= 56)
18825 {
18826
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_igetzf(&temp_combo.z_height,f))
18827 return qe_invalid;
18828
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_igetzf(&temp_combo.z_step_height,f))
18829 return qe_invalid;
18830 34742 }
18831
2/2
✓ Branch 0 taken 3208 times.
✓ Branch 1 taken 33412 times.
36620 if(s_version >= 60)
18832 {
18833
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.dive_under_level,f))
18834 return qe_invalid;
18835 33412 }
18836 36620 }
18837
2/2
✓ Branch 0 taken 1399558 times.
✓ Branch 1 taken 3 times.
1399561 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18838 {
18839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18840 return ret;
18841 3 }
18842 1399561 }
18843 1690804 update_combo(temp_combo, s_version);
18844 1690804 return 0;
18845 1690804 }
18846
18847 498 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18848 {
18849
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18850
18851 498 word section_version=0;
18852 498 word combos_used=0;
18853 int32_t dummy;
18854 byte padding;
18855 498 newcombo temp_combo;
18856
18857
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
18858 {
18859
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 reset_all_combo_animations();
18860
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 init_combo_classes();
18861
18862
2/2
✓ Branch 0 taken 32444160 times.
✓ Branch 1 taken 497 times.
32444657 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18863
1/2
✓ Branch 0 taken 32444160 times.
✗ Branch 1 not taken.
32444160 combobuf[q].clear();
18864 497 }
18865
18866
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 if(version > 0x192) //Version info
18867 {
18868
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&section_version,f))
18869 {
18870 return qe_invalid;
18871 }
18872 474 FFCore.quest_format[vCombos] = section_version;
18873
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!read_deprecated_section_cversion(f))
18874 {
18875 return qe_invalid;
18876 }
18877
18878 //section size
18879
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
18880 {
18881 return qe_invalid;
18882 }
18883 474 }
18884
18885
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 288 times.
498 if(section_version > 32) //Cleanup time!
18886 {
18887
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetw(&combos_used,f))
18888 {
18889 return qe_invalid;
18890 }
18891
2/2
✓ Branch 0 taken 1690804 times.
✓ Branch 1 taken 210 times.
1691014 for(int32_t i=0; i<combos_used; i++)
18892 {
18893
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 auto ret = readcombo_loop(f,section_version,temp_combo);
18894
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(ret) return ret;
18895
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(i>=start_combo)
18896 {
18897
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18898 {
18899 temp_combo.script = 0;
18900 for(int q = 0; q < 8; ++q)
18901 temp_combo.initd[q] = 0;
18902 }
18903
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 combobuf[i] = temp_combo;
18904 1690804 }
18905 1690804 }
18906 210 }
18907 else //Call the old function for all old versions
18908 {
18909
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18911 }
18912
18913
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
498 if (should_skip)
18914 1 return 0;
18915
18916
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 201 times.
497 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18917 {
18918 201 combobuf[0].walk = 0xF0;
18919 201 combobuf[0].type = 0;
18920 201 combobuf[0].flag = 0;
18921 201 }
18922
18923
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 setup_combo_animations();
18924
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 setup_combo_animations2();
18925 497 return 0;
18926 498 }
18927
18928 415 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18929 {
18930 //these are here to bypass compiler warnings about unused arguments
18931 415 Header=Header;
18932 415 version=version;
18933 415 build=build;
18934
18935 int32_t dummy;
18936 415 word sversion=0, c_sversion;
18937
18938 //section version info
18939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&sversion,f))
18940 {
18941 return qe_invalid;
18942 }
18943
18944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (sversion > V_COMBOALIASES)
18945 return qe_version;
18946
18947 415 FFCore.quest_format[vComboAliases] = sversion;
18948
18949
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&c_sversion,f))
18950 {
18951 return qe_invalid;
18952 }
18953
18954 //section size
18955
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
18956 {
18957 return qe_invalid;
18958 }
18959
18960 415 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18961
18962
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18963 {
18964 200 max_num_combo_aliases = MAX250COMBOALIASES;
18965 200 }
18966
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18967 {
18968 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18969 }
18970
18971
2/2
✓ Branch 0 taken 2170880 times.
✓ Branch 1 taken 415 times.
2171295 for(int32_t j=0; j<max_num_combo_aliases; j++)
18972 {
18973 byte width,height,mask,tempcset;
18974 int32_t count;
18975 word tempword;
18976 byte tempbyte;
18977
18978
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_igetw(&tempword,f))
18979 {
18980 return qe_invalid;
18981 }
18982
18983 2170880 combo_aliases[j].combo = tempword;
18984
18985
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&tempbyte,f))
18986 {
18987 return qe_invalid;
18988 }
18989
18990 2170880 combo_aliases[j].cset = tempbyte;
18991
18992
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&width,f))
18993 {
18994 return qe_invalid;
18995 }
18996
18997
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&height,f))
18998 {
18999 return qe_invalid;
19000 }
19001
19002
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&mask,f))
19003 {
19004 return qe_invalid;
19005 }
19006
19007 2170880 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
19008
19009 2170880 combo_aliases[j].width = width;
19010 2170880 combo_aliases[j].height = height;
19011 2170880 combo_aliases[j].layermask = mask;
19012 2170880 combo_aliases[j].combos.clear();
19013 2170880 combo_aliases[j].csets.clear();
19014
19015
2/2
✓ Branch 0 taken 2229109 times.
✓ Branch 1 taken 2170880 times.
4399989 for(int32_t k=0; k<count; k++)
19016 {
19017
1/2
✓ Branch 0 taken 2229109 times.
✗ Branch 1 not taken.
2229109 if(!p_igetw(&tempword,f))
19018 {
19019 return qe_invalid;
19020 }
19021
19022 2229109 combo_aliases[j].combos[k] = tempword;
19023 2229109 }
19024
19025
2/2
✓ Branch 0 taken 2229109 times.
✓ Branch 1 taken 2170880 times.
4399989 for(int32_t k=0; k<count; k++)
19026 {
19027
1/2
✓ Branch 0 taken 2229109 times.
✗ Branch 1 not taken.
2229109 if(!p_getc(&tempcset,f))
19028 {
19029 return qe_invalid;
19030 }
19031
19032 2229109 combo_aliases[j].csets[k] = tempcset;
19033 2229109 }
19034 2170880 }
19035
19036 //Combo pools!
19037 415 word num_combo_pools = 0;
19038
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 210 times.
415 if(sversion >= 4)
19039 {
19040
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetw(&num_combo_pools,f))
19041 {
19042 return qe_invalid;
19043 }
19044 210 }
19045
19046
2/2
✓ Branch 0 taken 3399680 times.
✓ Branch 1 taken 415 times.
3400095 for(combo_pool& pool : combo_pools)
19047 {
19048 3399680 pool.clear();
19049 }
19050
19051 415 combo_pool temp_cpool;
19052
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 415 times.
1123 for(word cp = 0; cp < num_combo_pools; ++cp)
19053 {
19054 708 int32_t num_combos_in_pool = 0;
19055
2/4
✓ Branch 0 taken 708 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 708 times.
✗ Branch 3 not taken.
708 if(!p_igetl(&num_combos_in_pool,f))
19056 {
19057 return qe_invalid;
19058 }
19059
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 106 times.
708 if(num_combos_in_pool < 1) continue; //nothing to read
19060
19061
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 temp_cpool.clear();
19062
19063 int32_t cp_cid; int8_t cp_cs; word cp_quant;
19064
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 2753 times.
3355 for(auto q = 0; q < num_combos_in_pool; ++q)
19065 {
19066
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_igetl(&cp_cid,f))
19067 {
19068 return qe_invalid;
19069 }
19070
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_getc(&cp_cs,f))
19071 {
19072 return qe_invalid;
19073 }
19074
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_igetw(&cp_quant,f))
19075 {
19076 return qe_invalid;
19077 }
19078
1/2
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
2753 temp_cpool.add(cp_cid, cp_cs, cp_quant);
19079 2753 }
19080
19081
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 combo_pools[cp] = temp_cpool;
19082 602 }
19083
19084 //Autocombos!
19085 415 word num_combo_autos = 0;
19086
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 217 times.
415 if (sversion >= 5)
19087 {
19088
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_igetw(&num_combo_autos, f))
19089 {
19090 return qe_invalid;
19091 }
19092 198 }
19093
19094
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 3399680 times.
3400095 for (combo_auto& cauto : combo_autos)
19095 {
19096
1/2
✓ Branch 0 taken 3399680 times.
✗ Branch 1 not taken.
3399680 cauto.clear(true);
19097 }
19098
19099
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 combo_auto temp_cauto;
19100
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 415 times.
569 for (word ca = 0; ca < num_combo_autos; ++ca)
19101 {
19102 byte type;
19103 int32_t display_cid, erase_cid;
19104 byte flags, arg;
19105
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&type, f))
19106 {
19107 return qe_invalid;
19108 }
19109
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&display_cid, f))
19110 {
19111 return qe_invalid;
19112 }
19113
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&erase_cid, f))
19114 {
19115 return qe_invalid;
19116 }
19117
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&flags, f))
19118 {
19119 return qe_invalid;
19120 }
19121
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&arg, f))
19122 {
19123 return qe_invalid;
19124 }
19125 154 int32_t num_combos_in_cauto = 0;
19126
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&num_combos_in_cauto, f))
19127 {
19128 return qe_invalid;
19129 }
19130
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 21 times.
154 if (num_combos_in_cauto < 1) continue; //nothing to read
19131
19132
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.clear();
19133
19134
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setType(type);
19135
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setDisplay(display_cid);
19136
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setEraseCombo(erase_cid);
19137
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setFlags(flags);
19138
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setArg(arg);
19139
19140 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
19141
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 3389 times.
3522 for (auto q = 0; q < num_combos_in_cauto; ++q)
19142 {
19143
2/4
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
3389 if (!p_getc(&ca_ctype, f))
19144 {
19145 return qe_invalid;
19146 }
19147
2/4
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
3389 if (!p_igetl(&ca_cid, f))
19148 {
19149 return qe_invalid;
19150 }
19151
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
19152 3389 }
19153
19154
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 combo_autos[ca] = temp_cauto;
19155 133 }
19156
19157 415 return 0;
19158 415 }
19159
19160 832 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
19161 {
19162
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
19163
19164 //these are here to bypass compiler warnings about unused arguments
19165 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
19166 //Capitalized cause it'll save you a headache. -Deedee
19167 832 start_cset=start_cset;
19168 832 max_csets=max_csets;
19169 832 word s_version=0;
19170
19171 832 miscQdata temp_misc;
19172
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 temp_misc = *Misc;
19173
19174 byte temp_colordata[48];
19175 char temp_palname[PALNAMESIZE+1];
19176
19177 int32_t dummy;
19178 word palcycles;
19179
19180
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(version > 0x192)
19181 {
19182 //section version info
19183
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&s_version,f))
19184 {
19185 return qe_invalid;
19186 }
19187
19188
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (s_version > V_CSETS)
19189 return qe_version;
19190
19191 808 FFCore.quest_format[vCSets] = s_version;
19192
19193
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&dummy,f))
19194 {
19195 return qe_invalid;
19196 }
19197
19198 //section size
19199
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&dummy,f))
19200 {
19201 return qe_invalid;
19202 }
19203 808 }
19204
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
832 if (s_version < 5)
19205 {
19206
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 593 times.
✓ Branch 3 taken 6 times.
617 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19207
19208 //finally... section data
19209 617 int32_t q = 0;
19210 617 int32_t p = -15;
19211
2/2
✓ Branch 0 taken 148080 times.
✓ Branch 1 taken 617 times.
148697 for(int32_t i=0; i<oldpdTOTAL; ++i)
19212 {
19213 148080 memset(temp_colordata, 0, 48);
19214
19215
2/4
✓ Branch 0 taken 148080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148080 times.
✗ Branch 3 not taken.
148080 if(!pfread(temp_colordata,48,f))
19216 {
19217 return qe_invalid;
19218 }
19219
19220
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 147840 times.
148080 if (should_skip)
19221 240 continue;
19222
19223 147840 memcpy(&colordata[q*48], temp_colordata, 48);
19224
19225 147840 ++q;
19226
8/8
✓ Branch 0 taken 137984 times.
✓ Branch 1 taken 9856 times.
✓ Branch 2 taken 10472 times.
✓ Branch 3 taken 127512 times.
✓ Branch 4 taken 1232 times.
✓ Branch 5 taken 9240 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1196 times.
147840 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19227 {
19228
1/2
✓ Branch 0 taken 10436 times.
✗ Branch 1 not taken.
10436 if (s_version < 5) //Bumping up the size of level palettes
19229 {
19230 10436 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19231 10436 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19232 10436 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19233 10436 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19234 10436 q+=4;
19235 10436 }
19236 else
19237 {
19238 for(int m = 0; m < 4; ++m)
19239 {
19240 memset(temp_colordata, 0, 48);
19241 if(!pfread(temp_colordata,48,f))
19242 {
19243 return qe_invalid;
19244 }
19245 memcpy(&colordata[q*48], temp_colordata, 48);
19246 ++q;
19247 }
19248 }
19249 10436 }
19250 147840 ++p;
19251 147840 }
19252
19253
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 599 times.
617 if(RealOldVerion)
19254 {
19255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19256 {
19257 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19258 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19259 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19260 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19261 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19262 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19263 18 }
19264 18 }
19265 else
19266 {
19267 599 memset(temp_colordata, 0, 48);
19268
19269
2/2
✓ Branch 0 taken 1876667 times.
✓ Branch 1 taken 599 times.
1877266 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19270 {
19271
2/4
✓ Branch 0 taken 1876667 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1876667 times.
✗ Branch 3 not taken.
1876667 if(!pfread(temp_colordata,48,f))
19272 {
19273 return qe_invalid;
19274 }
19275
19276
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1873534 times.
1876667 if (should_skip)
19277 3133 continue;
19278
19279 1873534 memcpy(&colordata[q*48], temp_colordata, 48);
19280
19281 1873534 ++q;
19282
7/8
✓ Branch 0 taken 1873534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144118 times.
✓ Branch 3 taken 1729416 times.
✓ Branch 4 taken 1196 times.
✓ Branch 5 taken 142922 times.
✓ Branch 6 taken 1068 times.
✓ Branch 7 taken 128 times.
1873534 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19283 {
19284
1/2
✓ Branch 0 taken 143990 times.
✗ Branch 1 not taken.
143990 if (s_version < 5) //Bumping up the size of level palettes
19285 {
19286 143990 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19287 143990 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19288 143990 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19289 143990 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19290 143990 q+=4;
19291 143990 }
19292 else
19293 {
19294 for(int m = 0; m < 4; ++m)
19295 {
19296 memset(temp_colordata, 0, 48);
19297 if(!pfread(temp_colordata,48,f))
19298 {
19299 return qe_invalid;
19300 }
19301 memcpy(&colordata[q*48], temp_colordata, 48);
19302 ++q;
19303 }
19304 }
19305 143990 }
19306 1873534 ++p;
19307 1873534 }
19308
19309
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 534 times.
599 if(s_version < 4)
19310 {
19311
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19312 {
19313 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19314 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19315 64 }
19316 65 }
19317 else
19318 {
19319
2/2
✓ Branch 0 taken 1777152 times.
✓ Branch 1 taken 534 times.
1777686 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19320 {
19321
2/4
✓ Branch 0 taken 1777152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1777152 times.
✗ Branch 3 not taken.
1777152 if(!pfread(temp_colordata,48,f))
19322 {
19323 return qe_invalid;
19324 }
19325
19326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1777152 times.
1777152 if (should_skip)
19327 continue;
19328
19329 1777152 memcpy(&colordata[q*48], temp_colordata, 48);
19330 1777152 ++q;
19331
5/6
✓ Branch 0 taken 1777152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136704 times.
✓ Branch 3 taken 1640448 times.
✓ Branch 4 taken 1068 times.
✓ Branch 5 taken 135636 times.
1777152 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19332 {
19333
1/2
✓ Branch 0 taken 135636 times.
✗ Branch 1 not taken.
135636 if (s_version < 5) //Bumping up the size of level palettes
19334 {
19335 135636 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19336 135636 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19337 135636 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19338 135636 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19339 135636 q+=4;
19340 135636 }
19341 else
19342 {
19343 for(int m = 0; m < 4; ++m)
19344 {
19345 memset(temp_colordata, 0, 48);
19346 if(!pfread(temp_colordata,48,f))
19347 {
19348 return qe_invalid;
19349 }
19350 memcpy(&colordata[q*48], temp_colordata, 48);
19351 ++q;
19352 }
19353 }
19354 135636 }
19355 1777152 ++p;
19356 1777152 }
19357
19358 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19359 }
19360 }
19361 617 }
19362 else
19363 {
19364
2/2
✓ Branch 0 taken 1881035 times.
✓ Branch 1 taken 215 times.
1881250 for(int32_t i=0; i<pdTOTAL255; ++i)
19365 {
19366 1881035 memset(temp_colordata, 0, 48);
19367
19368
2/4
✓ Branch 0 taken 1881035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1881035 times.
✗ Branch 3 not taken.
1881035 if(!pfread(temp_colordata,48,f))
19369 {
19370 return qe_invalid;
19371 }
19372
19373 1881035 memcpy(&colordata[i*48], temp_colordata, 48);
19374 1881035 }
19375 }
19376
19377
4/4
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 169 times.
✓ Branch 3 taken 662 times.
832 if (!should_skip && s_version < 6)
19378 {
19379
2/2
✓ Branch 0 taken 278008224 times.
✓ Branch 1 taken 662 times.
278008886 for (int i = 0; i < psTOTAL255; i++)
19380 {
19381 278008224 colordata[i] = _rgb_scale_6[colordata[i]];
19382 278008224 }
19383 662 }
19384
19385
5/6
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 808 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
832 if((version < 0x192)||((version == 0x192)&&(build<76)))
19386 {
19387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19388 18 init_palnames();
19389 18 }
19390 else
19391 {
19392 814 int32_t palnamestoread = 0;
19393
19394
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 749 times.
814 if(s_version < 3)
19395 65 palnamestoread = OLDMAXLEVELS;
19396 else
19397 749 palnamestoread = 512;
19398
19399
2/2
✓ Branch 0 taken 400128 times.
✓ Branch 1 taken 814 times.
400942 for(int32_t i=0; i<palnamestoread; ++i)
19400 {
19401
2/4
✓ Branch 0 taken 400128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 400128 times.
✗ Branch 3 not taken.
400128 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19402 {
19403 return qe_invalid;
19404 }
19405
19406
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 399872 times.
400128 if (!should_skip)
19407 399872 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19408 400128 }
19409
19410
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 813 times.
814 if (should_skip)
19411 1 return 0;
19412
19413
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 813 times.
17197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19414 {
19415 16384 memset(palnames[i], 0, PALNAMESIZE);
19416 16384 }
19417 }
19418
19419
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 808 times.
831 if(version > 0x192)
19420 {
19421
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 206848 times.
207656 for(int32_t i=0; i<256; i++)
19422 {
19423
2/2
✓ Branch 0 taken 620544 times.
✓ Branch 1 taken 206848 times.
827392 for(int32_t j=0; j<3; j++)
19424 {
19425 620544 temp_misc.cycles[i][j].first=0;
19426 620544 temp_misc.cycles[i][j].count=0;
19427 620544 temp_misc.cycles[i][j].speed=0;
19428 620544 }
19429 206848 }
19430
19431
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&palcycles,f))
19432 {
19433 return qe_invalid;
19434 }
19435
19436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if (palcycles > NUM_PAL_CYCLES)
19437 {
19438 return qe_invalid;
19439 }
19440
19441
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 22465 times.
23273 for(int32_t i=0; i<palcycles; i++)
19442 {
19443
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19444 {
19445
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19446 {
19447 return qe_invalid;
19448 }
19449 67395 }
19450
19451
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19452 {
19453
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19454 {
19455 return qe_invalid;
19456 }
19457 67395 }
19458
19459
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19460 {
19461
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19462 {
19463 return qe_invalid;
19464 }
19465 67395 }
19466 22465 }
19467
19468
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 *Misc = temp_misc;
19469 808 }
19470
19471 831 return 0;
19472 832 }
19473
19474 832 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19475 {
19476
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19477
19478 832 int32_t tiles_used=0;
19479 832 word section_version = 0;
19480 832 int32_t section_size= 0;
19481 832 byte *temp_tile = new byte[tilesize(tf32Bit)];
19482
19483 //Tile Expansion
19484 //if ( version >= 0x254 && build >= 41 )
19485
4/4
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 611 times.
832 if (version < 0x254 && build < 41)
19486 {
19487 611 max_tiles = ZC250MAXTILES;
19488 611 }
19489
19490
19491
2/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19492 {
19493 if(!init_tiles_for_190(true, Header))
19494 {
19495 al_trace("Unable to initialize tiles\n");
19496 }
19497
19498 delete[] temp_tile;
19499 temp_tile=NULL;
19500 return 0;
19501 }
19502 else
19503 {
19504
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 808 times.
832 if(version > 0x192)
19505 {
19506 //section version info
19507
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetw(&section_version,f))
19508 {
19509 delete[] temp_tile;
19510 return qe_invalid;
19511 }
19512
19513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if (section_version > V_TILES)
19514 return qe_version;
19515
19516 808 FFCore.quest_format[vTiles] = section_version;
19517
19518
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!read_deprecated_section_cversion(f))
19519 {
19520 delete[] temp_tile;
19521 return qe_invalid;
19522 }
19523
19524 //section size
19525
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetl(&section_size,f))
19526 {
19527 delete[] temp_tile;
19528 return qe_invalid;
19529 }
19530 808 }
19531
19532 //if ( build < 41 )
19533 //{
19534 // tiles_used = ZC250MAXTILES;
19535 //}
19536
19537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(version < 0x174)
19538 {
19539 tiles_used=TILES_PER_PAGE*4;
19540 } //no expanded tile space
19541
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 814 times.
832 else if(version < 0x191)
19542 {
19543 18 tiles_used=OLDMAXTILES;
19544 18 }
19545 else
19546 {
19547 //finally... section data
19548
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
814 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19549 {
19550
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tiles_used,f))
19551 {
19552 delete[] temp_tile;
19553 return qe_invalid;
19554 }
19555 215 }
19556 else
19557 {
19558
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(!p_igetw(&tiles_used,f))
19559 {
19560 delete[] temp_tile;
19561 return qe_invalid;
19562 }
19563 }
19564 }
19565
19566
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tiles_used=zc_min(tiles_used, max_tiles);
19567
19568 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19569 //if ( version < 0x254 && build < 41 )
19570
3/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if ( version < 0x254 || (version == 0x254 && build < 41) )
19571 //if ( build < 41 )
19572 {
19573
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19574 617 }
19575 else //2.55
19576 {
19577
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19578 }
19579
19580 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19581
19582
19583
2/2
✓ Branch 0 taken 19322296 times.
✓ Branch 1 taken 832 times.
19323128 for(int32_t i=0; i<tiles_used; ++i)
19584 {
19585 19322296 byte format=tf4Bit;
19586 19322296 memset(temp_tile, 0, tilesize(tf32Bit));
19587
19588
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 16336840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19322296 if((version>0x211)||((version==0x211)&&(build>4)))
19589 {
19590
1/2
✓ Branch 0 taken 16336840 times.
✗ Branch 1 not taken.
16336840 if(!p_getc(&format,f))
19591 {
19592 delete[] temp_tile;
19593 return qe_invalid;
19594 }
19595 16336840 }
19596
4/4
✓ Branch 0 taken 8374310 times.
✓ Branch 1 taken 10947986 times.
✓ Branch 2 taken 3872830 times.
✓ Branch 3 taken 4501480 times.
19322296 if(section_version > 2 && !format)
19597 {
19598 4501480 reset_tile(buf,start_tile+i,tf4Bit);
19599 4501480 continue;
19600 }
19601
19602
2/2
✓ Branch 0 taken 14311616 times.
✓ Branch 1 taken 509200 times.
14820816 int size = format == tf4Bit ? 128 : tilesize(format);
19603
1/2
✓ Branch 0 taken 14820816 times.
✗ Branch 1 not taken.
14820816 if(!pfread(temp_tile,size,f))
19604 {
19605 delete[] temp_tile;
19606 return qe_invalid;
19607 }
19608
19609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14820816 times.
14820816 if (should_skip)
19610 continue;
19611
19612 14820816 buf[start_tile+i].format=format;
19613
19614
2/2
✓ Branch 0 taken 14607142 times.
✓ Branch 1 taken 213674 times.
14820816 if(buf[start_tile+i].data)
19615 {
19616 14607142 free(buf[start_tile+i].data);
19617 14607142 buf[start_tile+i].data=NULL;
19618 14607142 }
19619
19620 14820816 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19621
19622
2/2
✓ Branch 0 taken 14311616 times.
✓ Branch 1 taken 509200 times.
14820816 if (format == tf4Bit)
19623 {
19624 byte temp[256];
19625 14311616 byte *si = temp_tile + 128;
19626 14311616 byte *di = temp + 256;
19627
19628
2/2
✓ Branch 0 taken 1831886848 times.
✓ Branch 1 taken 14311616 times.
1846198464 for(int i=127; i>=0; --i)
19629 {
19630 1831886848 (*(--di)) = (*(--si)) >> 4;
19631 1831886848 (*(--di)) = (*si) & 15;
19632 1831886848 }
19633
19634 14311616 memcpy(buf[start_tile+i].data,temp,256);
19635 14311616 }
19636 else
19637 {
19638 509200 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19639 }
19640 14820816 }
19641 }
19642
19643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (should_skip)
19644 return 0;
19645
19646
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
832 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19647 {
19648
2/2
✓ Branch 0 taken 91920660 times.
✓ Branch 1 taken 617 times.
91921277 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19649 {
19650
19651 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19652 91920660 reset_tile(buf,q,tf4Bit);
19653
19654
19655 /*
19656
19657 byte tempbyte;
19658 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19659 {
19660 tempbyte=buf[ZC250MAXTILES-1].data[i];
19661 buf[q].data[i] = tempbyte;
19662 }
19663 //int32_t temp = tempbyte=buf[130].data[i];
19664 //buf[q].data = buf[ZC250MAXTILES-1].data;
19665 */
19666 //reset_tile(buf,q,tf4Bit);
19667 91920660 }
19668
19669 617 }
19670
19671
4/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215 times.
832 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19672 {
19673
2/2
✓ Branch 0 taken 30945450 times.
✓ Branch 1 taken 617 times.
30946067 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19674 {
19675 30945450 reset_tile(buf,i,tf4Bit);
19676 30945450 }
19677 617 }
19678 else
19679 {
19680
2/2
✓ Branch 0 taken 37169474 times.
✓ Branch 1 taken 215 times.
37169689 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19681 {
19682 37169474 reset_tile(buf,i,tf4Bit);
19683 37169474 }
19684 }
19685
19686
5/6
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 808 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
832 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19687 {
19688
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19689 {
19690 byte tempbyte;
19691 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19692
19693
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19694 {
19695 1536 tempbyte=buf[23].data[i];
19696 1536 buf[23].data[i]=buf[24].data[i];
19697 1536 buf[24].data[i]=buf[25].data[i];
19698 1536 buf[25].data[i]=buf[26].data[i];
19699 1536 buf[26].data[i]=tempbyte;
19700 1536 }
19701 //swim tiles are out of order, too, but nobody cared? -Z
19702
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19703 {
19704 1536 tempbyte=buf[floattile+11].data[i];
19705 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19706 1536 buf[floattile+12].data[i]=tempbyte;
19707 1536 }
19708 6 }
19709 24 }
19710
19711
3/6
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19712 {
19713
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19714 {
19715 byte tempbyte;
19716
19717
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19718 {
19719 5632 tempbyte=buf[130].data[i];
19720 5632 buf[130].data[i]=buf[132].data[i];
19721 5632 buf[132].data[i]=tempbyte;
19722
19723 5632 tempbyte=buf[131].data[i];
19724 5632 buf[131].data[i]=buf[133].data[i];
19725 5632 buf[133].data[i]=tempbyte;
19726 5632 }
19727 22 }
19728 83 }
19729
19730 832 al_trace("Registering blank tiles\n");
19731 832 register_blank_tiles();
19732
19733 //memset(temp_tile, 0, tilesize(tf32Bit));
19734
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 delete[] temp_tile;
19735 832 temp_tile=NULL;
19736 832 return 0;
19737 832 }
19738
19739 497 int32_t readmidis(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19740 {
19741
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19742
19743 static byte fake_midi_flags[32];
19744
19745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19746 int32_t dummy;
19747 word dummy2;
19748 // zcmidi_ temp_midi;
19749 int32_t tunes_to_read;
19750 497 int32_t tune_count=0;
19751 497 word section_version=0;
19752 497 zctune temp;
19753
19754
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version < 0x193)
19755 {
19756 // mf=Header->data_flags+ZQ_MIDIS2;
19757
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19758 {
19759 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19760 22 }
19761 else
19762 {
19763 1 tunes_to_read=MAXCUSTOMTUNES;
19764 }
19765 23 }
19766 else
19767 {
19768 //section version info
19769
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&section_version,f))
19770 {
19771 return qe_invalid;
19772 }
19773
19774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (section_version > V_MIDIS)
19775 return qe_version;
19776
19777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (!should_skip)
19778 474 FFCore.quest_format[vMIDIs] = section_version;
19779
19780
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&dummy2,f))
19781 {
19782 return qe_invalid;
19783 }
19784
19785 //section size
19786
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
19787 {
19788 return qe_invalid;
19789 }
19790
19791 //finally... section data
19792
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!pfread(midi_flags,sizeof(midi_flags),f))
19793 {
19794 return qe_invalid;
19795 }
19796
19797 474 tunes_to_read=MAXCUSTOMTUNES;
19798 }
19799
19800
2/2
✓ Branch 0 taken 125244 times.
✓ Branch 1 taken 497 times.
125741 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19801 {
19802
2/2
✓ Branch 0 taken 10331 times.
✓ Branch 1 taken 114913 times.
125244 if(get_bit(mf, i))
19803 {
19804 10331 ++tune_count;
19805 10331 }
19806 125244 }
19807
19808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (!should_skip)
19809 497 reset_tunes(tunes); //reset_midis(midis);
19810
19811
2/2
✓ Branch 0 taken 120404 times.
✓ Branch 1 taken 497 times.
120901 for(int32_t i=0; i<tunes_to_read; i++)
19812 {
19813 120404 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19814
19815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120404 times.
120404 if (!should_skip)
19816 120404 tunes[i].reset(); // reset_midi(midis+i);
19817
19818
2/2
✓ Branch 0 taken 110073 times.
✓ Branch 1 taken 10331 times.
120404 if(get_bit(mf,i))
19819 {
19820
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7668 times.
10331 if(section_version < 4)
19821 {
19822
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19823 {
19824 return qe_invalid;
19825 }
19826 2663 }
19827 else
19828 {
19829
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19830 {
19831 return qe_invalid;
19832 }
19833 }
19834
19835
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!p_igetl(&temp.start,f))
19836 {
19837 return qe_invalid;
19838 }
19839
19840
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!p_igetl(&temp.loop_start,f))
19841 {
19842 return qe_invalid;
19843 }
19844
19845
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!p_igetl(&temp.loop_end,f))
19846 {
19847 return qe_invalid;
19848 }
19849
19850
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!p_igetw(&temp.loop,f))
19851 {
19852 return qe_invalid;
19853 }
19854
19855
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!p_igetw(&temp.volume,f))
19856 {
19857 return qe_invalid;
19858 }
19859
19860
2/2
✓ Branch 0 taken 10082 times.
✓ Branch 1 taken 249 times.
10331 if(Header->zelda_version < 0x193)
19861 {
19862
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19863 {
19864 return qe_invalid;
19865 }
19866 249 }
19867
19868
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7668 times.
10331 if(section_version >= 3)
19869 {
19870
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19871 {
19872 return qe_invalid;
19873 }
19874 7668 }
19875
19876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10331 times.
10331 if (!should_skip)
19877 10331 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19878
19879
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7668 times.
10331 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19880 {
19881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19882 {
19883 if (read_midi(f)==NULL)
19884 {
19885 return qe_invalid;
19886 }
19887
19888 continue;
19889 }
19890
19891 // old format - a midi is a midi
19892
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19893 {
19894 return qe_invalid;
19895 }
19896 2663 }
19897 else
19898 {
19899 byte format;
19900
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if(!pfread(&format,sizeof(format),f))
19901 {
19902 return qe_invalid;
19903 }
19904
19905 // MIDI is the only format saved here.
19906 // Never did more than MIDI for a zctune, and no plans to now.
19907
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if (format != MFORMAT_MIDI)
19908 {
19909 return qe_invalid;
19910 }
19911
19912 7668 tunes[i].data = read_midi(f);
19913
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if (!tunes[i].data)
19914 {
19915 return qe_invalid;
19916 }
19917 }
19918 10331 }
19919 120404 }
19920
19921 497 return 0;
19922 497 }
19923
19924 497 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19925 {
19926
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19927
19928 int32_t dummy;
19929 ZCHEATS tempzcheats;
19930 497 char temp_use_cheats=1;
19931 497 memset(&tempzcheats, 0, sizeof(tempzcheats));
19932 497 word s_version = 0;
19933
19934
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version > 0x192)
19935 {
19936 //section version info
19937
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
19938 {
19939 return qe_invalid;
19940 }
19941
19942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_CHEATS)
19943 return qe_version;
19944
19945 474 FFCore.quest_format[vCheats] = s_version;
19946
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&dummy,f))
19947 {
19948 return qe_invalid;
19949 }
19950
19951 //section size
19952
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
19953 {
19954 return qe_invalid;
19955 }
19956
19957 //finally... section data
19958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(!p_getc(&temp_use_cheats,f))
19959 {
19960 return qe_invalid;
19961 }
19962 474 }
19963
19964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(Header->data_flags[ZQ_CHEATS2])
19965 {
19966
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(!p_igetl(&tempzcheats.flags,f))
19967 {
19968 return qe_invalid;
19969 }
19970
19971
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19972 {
19973 return qe_invalid;
19974 }
19975 497 }
19976
19977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (should_skip)
19978 return 0;
19979
19980 497 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19981 497 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19982
19983 497 return 0;
19984 497 }
19985
19986 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19987 {
19988
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19989
19990 byte padding, tempbyte;
19991
19992 // Legacy item properties (now integrated into itemdata)
19993 byte sword_hearts[4];
19994 byte beam_hearts[4];
19995 299 byte beam_percent=0;
19996 word beam_power[4];
19997 299 byte hookshot_length=99;
19998 299 byte hookshot_links=100;
19999 299 byte longshot_length=99;
20000 299 byte longshot_links=100;
20001 299 byte moving_fairy_hearts=3;
20002 299 byte moving_fairy_heart_percent=0;
20003 299 byte stationary_fairy_hearts=3;
20004 299 byte stationary_fairy_heart_percent=0;
20005 299 byte moving_fairy_magic=0;
20006 299 byte moving_fairy_magic_percent=0;
20007 299 byte stationary_fairy_magic=0;
20008 299 byte stationary_fairy_magic_percent=0;
20009 299 byte blue_potion_hearts=100;
20010 299 byte blue_potion_heart_percent=1;
20011 299 byte red_potion_hearts=100;
20012 299 byte red_potion_heart_percent=1;
20013 299 byte blue_potion_magic=100;
20014 299 byte blue_potion_magic_percent=1;
20015 299 byte red_potion_magic=100;
20016 299 byte red_potion_magic_percent=1;
20017
20018 299 byte bomb_ratio = 4;
20019
20020 299 subscr_mode = 0;
20021
20022 /* HIGHLY UNORTHODOX UPDATING THING, by L
20023 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
20024 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
20025 * changing from 13 to 14.
20026 */
20027
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
20028 82 fixpolsvoice=true;
20029
20030 /* End highly unorthodox updating thing */
20031
20032
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
20033 111 temp_zinit.jump_hero_layer_threshold=0;
20034
20035
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
20036 {
20037 char temp;
20038
20039 //new-style items
20040
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
20041 {
20042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
20043 return qe_invalid;
20044
20045 55552 temp_zinit.set_item(j, temp != 0);
20046 55552 }
20047 217 }
20048
20049
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
20050 {
20051 char temp;
20052
20053 //finally... section data
20054
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20055 //new only
20056
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20057 {
20058 //OLD-style items... sigh
20059
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
20060 {
20061
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20062 {
20063 return qe_invalid;
20064 }
20065
20066 60 temp_zinit.set_item(iRaft, temp != 0);
20067
20068
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20069 {
20070 return qe_invalid;
20071 }
20072
20073 60 temp_zinit.set_item(iLadder, temp != 0);
20074
20075
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20076 {
20077 return qe_invalid;
20078 }
20079
20080 60 temp_zinit.set_item(iBook, temp != 0);
20081
20082
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20083 {
20084 return qe_invalid;
20085 }
20086
20087 60 temp_zinit.set_item(iMKey, temp != 0);
20088
20089
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094 60 temp_zinit.set_item(iFlippers, temp != 0);
20095
20096
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20097 {
20098 return qe_invalid;
20099 }
20100
20101 60 temp_zinit.set_item(iBoots, temp != 0);
20102 60 }
20103 277 }
20104
20105
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20106 {
20107 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
20108
20109
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
20110 {
20111 return qe_invalid;
20112 }
20113
20114
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
20115 {
20116 return qe_invalid;
20117 }
20118
20119
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
20120 {
20121 return qe_invalid;
20122 }
20123
20124
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
20125 {
20126 return qe_invalid;
20127 }
20128
20129
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
20135 {
20136 return qe_invalid;
20137 }
20138
20139
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
20140 {
20141 return qe_invalid;
20142 }
20143
20144 //old only
20145
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20146 {
20147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
20148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
20149
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
20150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
20151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
20152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
20153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
20154 4 }
20155
20156 //rings start at level 2... wtf
20157 //account for this -DD
20158 64 tempring <<= 1;
20159 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
20160 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
20161 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
20162 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
20163 //bracelet ALSO starts at level 2 :-( -DD
20164 64 tempbracelet<<=1;
20165 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
20166 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
20167 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
20168
20169 //new only
20170
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
20171 {
20172
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20173 {
20174
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20175 {
20176 return qe_invalid;
20177 }
20178 32 }
20179 1 }
20180
20181 char tempcandle, tempboomerang, temparrow, tempwhistle;
20182
20183
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
20184 {
20185 return qe_invalid;
20186 }
20187
20188
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
20189 {
20190 return qe_invalid;
20191 }
20192
20193
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
20194 {
20195 return qe_invalid;
20196 }
20197
20198
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
20199 {
20200 return qe_invalid;
20201 }
20202
20203 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
20204
20205
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
20206 {
20207 return qe_invalid;
20208 }
20209
20210 //old only
20211
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20212 {
20213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20217 4 }
20218
20219 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20220 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20221 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20222 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20223 //What about the potion...?
20224
20225 64 }
20226
20227
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20228 {
20229 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20230 //to jab out my eye...
20231
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20232 return qe_invalid;
20233 264 temp_zinit.counter[crBOMBS] = padding;
20234
20235
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20236 return qe_invalid;
20237 264 temp_zinit.counter[crSBOMBS] = padding;
20238 264 }
20239
20240 //Back to more OLD item code
20241
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20242 {
20243
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20244 //new only
20245
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20246 {
20247
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20248 {
20249 return qe_invalid;
20250 }
20251
20252 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20253
20254
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20255 {
20256 return qe_invalid;
20257 }
20258
20259 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20260
20261
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20262 {
20263 return qe_invalid;
20264 }
20265
20266 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20267
20268
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20269 {
20270 return qe_invalid;
20271 }
20272
20273 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20274
20275
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20276 {
20277 return qe_invalid;
20278 }
20279
20280 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20281
20282
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20283 {
20284 return qe_invalid;
20285 }
20286
20287 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20288
20289
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20290 {
20291 return qe_invalid;
20292 }
20293
20294 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20295
20296
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20297 {
20298 return qe_invalid;
20299 }
20300
20301 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20302
20303
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20304 {
20305 return qe_invalid;
20306 }
20307
20308 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20309
20310
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20311 {
20312 return qe_invalid;
20313 }
20314
20315
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20316 {
20317
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20318 {
20319
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20320 {
20321 return qe_invalid;
20322 }
20323 32 }
20324 1 }
20325 60 }
20326 64 }
20327
20328 //old only
20329
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20330 {
20331 byte equipment, tmpitm; //bit flags
20332
20333
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20334 {
20335 return qe_invalid;
20336 }
20337
20338 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20339 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20340 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20341 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20342 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20343 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20344
20345
20346
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20347 {
20348 return qe_invalid;
20349 }
20350
20351 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20352 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20353 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20354 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20355 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20356 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20357 4 }
20358
20359
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20360 return qe_invalid;
20361 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20362
20363
20364
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20365 {
20366 byte temphp;
20367
20368
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20369 {
20370 return qe_invalid;
20371 }
20372
20373 64 temp_zinit.counter[crLIFE]=temphp;
20374
20375
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20376 {
20377 return qe_invalid;
20378 }
20379
20380 64 temp_zinit.cont_heart=temphp;
20381 64 }
20382 else
20383 {
20384
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20385 {
20386 return qe_invalid;
20387 }
20388
20389
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20390 {
20391 return qe_invalid;
20392 }
20393 }
20394
20395
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20396 {
20397 return qe_invalid;
20398 }
20399
20400
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20401 {
20402
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20403 {
20404 return qe_invalid;
20405 }
20406
20407
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20408 {
20409 if(get_qr(qr_BRANGPICKUP+1))
20410 temp_zinit.hcp_per_hc = 0xFF;
20411
20412 //Dispose of legacy rule
20413 set_qr(qr_BRANGPICKUP+1, 0);
20414 }
20415 217 }
20416
20417
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20418 {
20419
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20420 return qe_invalid;
20421 264 temp_zinit.mcounter[crBOMBS] = padding;
20422 264 }
20423
20424
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20425 {
20426 return qe_invalid;
20427 }
20428
20429
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20430 {
20431 return qe_invalid;
20432 }
20433
20434
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20435 return qe_invalid;
20436
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20437
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20438
20439 281 int level_count = 32;
20440
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20441 217 level_count = 64;
20442 byte tmp_map[64];
20443 byte tmp_compass[64];
20444
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20445
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20446 return qe_invalid;
20447
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20448
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20449 return qe_invalid;
20450
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20451 {
20452
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20453
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20454 127488 }
20455
20456
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20457 //new only
20458
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20459 {
20460 byte tmp_boss_key[64];
20461
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20462 {
20463
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20464 {
20465 return qe_invalid;
20466 }
20467 15808 }
20468
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20469 {
20470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20471 126464 }
20472 277 }
20473
20474 byte tmpmisc[16];
20475
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20476
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20477 return qe_invalid;
20478 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20479 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20480 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20481
20482
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20483
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20484 64 return qe_invalid;
20485
20486
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20487 {
20488 return qe_invalid;
20489 }
20490
20491
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20492 {
20493 return qe_invalid;
20494 }
20495
20496
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20497 {
20498 byte tempmp;
20499
20500
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20501 {
20502 return qe_invalid;
20503 }
20504
20505 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20506
20507
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20508 {
20509 return qe_invalid;
20510 }
20511
20512 64 temp_zinit.counter[crMAGIC]=tempmp;
20513 64 }
20514 else
20515 {
20516
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20517 {
20518 return qe_invalid;
20519 }
20520
20521
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20522 {
20523 return qe_invalid;
20524 }
20525 }
20526
20527
20528
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20529 {
20530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20531 {
20532 64 temp_zinit.mcounter[crMAGIC]*=32;
20533 64 temp_zinit.counter[crMAGIC]*=32;
20534 64 }
20535
20536
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20537 {
20538
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20539 {
20540 return qe_invalid;
20541 }
20542 256 }
20543
20544
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20545 {
20546 return qe_invalid;
20547 }
20548 64 }
20549 else
20550 {
20551
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20552 return qe_invalid;
20553
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20554 temp_zinit.bomb_ratio = 1;
20555 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20556 }
20557
20558
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20559 {
20560 byte tempbp;
20561
20562
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20563 {
20564
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20565 {
20566 return qe_invalid;
20567 }
20568
20569 256 beam_power[i]=tempbp;
20570 256 }
20571
20572
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20573 {
20574 return qe_invalid;
20575 }
20576
20577
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20578 {
20579 if(!p_getc(&hookshot_length,f))
20580 {
20581 return qe_invalid;
20582 }
20583
20584 if(!p_getc(&longshot_links,f))
20585 {
20586 return qe_invalid;
20587 }
20588
20589 if(!p_getc(&longshot_length,f))
20590 {
20591 return qe_invalid;
20592 }
20593 }
20594 64 }
20595
20596
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20597 {
20598 return qe_invalid;
20599 }
20600
20601
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20602 {
20603 return qe_invalid;
20604 }
20605
20606
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20607 return qe_invalid;
20608
20609 //old only
20610
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20611 {
20612 byte tmp_boss_key[32];
20613
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20614 {
20615
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20616 {
20617 return qe_invalid;
20618 }
20619 128 }
20620
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20621 {
20622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20623 1024 }
20624 4 }
20625
20626
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20627 {
20628
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20629 {
20630
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20631 {
20632 return qe_invalid;
20633 }
20634
20635 60 temp_zinit.start_dmap = (word)tempbyte;
20636 60 }
20637 else
20638 {
20639
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20640 {
20641 return qe_invalid;
20642 }
20643 }
20644
20645
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20646 {
20647 return qe_invalid;
20648 }
20649 277 }
20650
20651
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20652 {
20653
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20654 return qe_invalid;
20655 200 temp_zinit.counter[crARROWS] = padding;
20656
20657
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20658 return qe_invalid;
20659 200 temp_zinit.mcounter[crARROWS] = padding;
20660 200 }
20661
20662
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20663 {
20664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20665 {
20666 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20667 {
20668 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20669 {
20670 return qe_invalid;
20671 }
20672 }
20673 }
20674 else
20675 {
20676
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20677 {
20678
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20679 {
20680 return qe_invalid;
20681 }
20682 111104 }
20683 }
20684 217 }
20685
20686
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20687 {
20688
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20689 {
20690 return qe_invalid;
20691 }
20692
20693
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20694 {
20695 return qe_invalid;
20696 }
20697
20698
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20699 {
20700 return qe_invalid;
20701 }
20702
20703
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20704 {
20705 return qe_invalid;
20706 }
20707
20708
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20709 {
20710 return qe_invalid;
20711 }
20712
20713
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20714 {
20715 return qe_invalid;
20716 }
20717
20718
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20719 {
20720 return qe_invalid;
20721 }
20722
20723
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20724 {
20725 return qe_invalid;
20726 }
20727
20728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20730 217 }
20731
20732
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20733 {
20734 if(!p_getc(&moving_fairy_hearts,f))
20735 {
20736 return qe_invalid;
20737 }
20738
20739 if(!p_getc(&moving_fairy_heart_percent,f))
20740 {
20741 return qe_invalid;
20742 }
20743 }
20744
20745
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20746 {
20747 if(!p_getc(&temp,f))
20748 {
20749 return qe_invalid;
20750 }
20751
20752 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20753 }
20754
20755
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20756 {
20757 if(!p_getc(&stationary_fairy_hearts,f))
20758 {
20759 return qe_invalid;
20760 }
20761
20762 if(!p_getc(&stationary_fairy_heart_percent,f))
20763 {
20764 return qe_invalid;
20765 }
20766
20767 if(!p_getc(&moving_fairy_magic,f))
20768 {
20769 return qe_invalid;
20770 }
20771
20772 if(!p_getc(&moving_fairy_magic_percent,f))
20773 {
20774 return qe_invalid;
20775 }
20776
20777 if(!p_getc(&stationary_fairy_magic,f))
20778 {
20779 return qe_invalid;
20780 }
20781
20782 if(!p_getc(&stationary_fairy_magic_percent,f))
20783 {
20784 return qe_invalid;
20785 }
20786
20787 if(!p_getc(&blue_potion_hearts,f))
20788 {
20789 return qe_invalid;
20790 }
20791
20792 if(!p_getc(&blue_potion_heart_percent,f))
20793 {
20794 return qe_invalid;
20795 }
20796
20797 if(!p_getc(&red_potion_hearts,f))
20798 {
20799 return qe_invalid;
20800 }
20801
20802 if(!p_getc(&red_potion_heart_percent,f))
20803 {
20804 return qe_invalid;
20805 }
20806
20807 if(!p_getc(&blue_potion_magic,f))
20808 {
20809 return qe_invalid;
20810 }
20811
20812 if(!p_getc(&blue_potion_magic_percent,f))
20813 {
20814 return qe_invalid;
20815 }
20816
20817 if(!p_getc(&red_potion_magic,f))
20818 {
20819 return qe_invalid;
20820 }
20821
20822 if(!p_getc(&red_potion_magic_percent,f))
20823 {
20824 return qe_invalid;
20825 }
20826 }
20827
20828
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20829
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20830 return qe_invalid;
20831
20832
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20833 {
20834
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20835 {
20836 return qe_invalid;
20837 }
20838 217 }
20839
20840
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20841 {
20842
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20843 {
20844 return qe_invalid;
20845 }
20846
20847
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20848 {
20849 return qe_invalid;
20850 }
20851 217 }
20852
20853
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20854 {
20855
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20856 {
20857 return qe_invalid;
20858 }
20859 217 temp_zinit.gravity = tempbyte*100;
20860
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20861 {
20862 return qe_invalid;
20863 }
20864
20865
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20866 {
20867 return qe_invalid;
20868 }
20869
20870
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20871 {
20872 return qe_invalid;
20873 }
20874
20875
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20876 {
20877 return qe_invalid;
20878 }
20879 217 }
20880
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20881 12 temp_zinit.msg_speed = 0;
20882
20883
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20884 {
20885
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20886 {
20887 return qe_invalid;
20888 }
20889 217 }
20890
20891 //expaned init data for larger values in 2.55
20892
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20893 {
20894
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20895 {
20896 return qe_invalid;
20897 }
20898
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20899 {
20900 return qe_invalid;
20901 }
20902
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20903 {
20904 return qe_invalid;
20905 }
20906
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20907 {
20908 return qe_invalid;
20909 }
20910
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20911 {
20912 return qe_invalid;
20913 }
20914
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20915 {
20916 return qe_invalid;
20917 }
20918
20919 17 }
20920
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20921 {
20922
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20923 {
20924 return qe_invalid;
20925 }
20926 17 }
20927 else
20928 {
20929 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20930 }
20931
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20932 {
20933
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20934 {
20935 return qe_invalid;
20936 }
20937 17 }
20938 else
20939 {
20940 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20941 }
20942 //old only
20943
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20944 {
20945 byte items2;
20946
20947
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20948 {
20949 return qe_invalid;
20950 }
20951
20952 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20953 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20954 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20955 4 }
20956
20957
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20958 {
20959
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20960 {
20961
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20962 {
20963 return qe_invalid;
20964 }
20965 480 }
20966
20967 //new only
20968
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20969 {
20970
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20971 {
20972 return qe_invalid;
20973 }
20974
20975
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20976 {
20977 return qe_invalid;
20978 }
20979 1 }
20980 5 }
20981 281 }
20982
20983
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20984 {
20985 //temp_zinit.shield=i_smallshield;
20986 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20987
20988
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20989 82 temp_zinit.set_item(sshieldid, true);
20990 82 }
20991
20992
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20993 {
20994 18 temp_zinit.mcounter[crLIFE]=3;
20995 18 temp_zinit.counter[crLIFE]=3;
20996 18 temp_zinit.cont_heart=3;
20997 18 temp_zinit.mcounter[crBOMBS]=8;
20998 18 }
20999
21000
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
21001 {
21002 18 sword_hearts[0]=0;
21003 18 sword_hearts[1]=5;
21004 18 sword_hearts[2]=12;
21005 18 sword_hearts[3]=21;
21006 18 }
21007
21008
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
21009 {
21010 18 temp_zinit.last_map=0;
21011 18 temp_zinit.last_screen=0;
21012 18 }
21013
21014
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
21015 {
21016 18 temp_zinit.mcounter[crMAGIC]=0;
21017 18 temp_zinit.counter[crMAGIC]=0;
21018 18 temp_zinit.magicdrainrate = 2;
21019 18 }
21020
21021
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
21022 {
21023
21024
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
21025 {
21026 72 beam_hearts[x]=100;
21027 72 }
21028
21029
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
21030 {
21031 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
21032 72 set_qr(qr_LENSHINTS+i,0);
21033 72 }
21034
21035
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
21036 {
21037 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
21038 72 }
21039
21040 18 set_qr(qr_HIDECARRIEDITEMS,0);
21041 18 hookshot_links=100;
21042 18 temp_zinit.msg_more_x=224;
21043 18 temp_zinit.msg_more_y=64;
21044 18 }
21045
21046 // Okay, let's put these legacy values into itemsbuf.
21047
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
21048
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
21049 {
21050
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
21051 {
21052 case iFairyStill:
21053 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
21054 82 itemsbuf[i].misc2 = stationary_fairy_magic;
21055 82 itemsbuf[i].misc3 = 0;
21056
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
21057
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
21058 82 break;
21059
21060 case iFairyMoving:
21061 82 itemsbuf[i].misc1 = moving_fairy_hearts;
21062 82 itemsbuf[i].misc2 = moving_fairy_magic;
21063 82 itemsbuf[i].misc3 = 50;
21064
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
21065
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
21066 82 break;
21067
21068 case iRPotion:
21069 82 itemsbuf[i].misc1 = red_potion_hearts;
21070 82 itemsbuf[i].misc2 = red_potion_magic;
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
21072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
21073 82 break;
21074
21075 case iBPotion:
21076 82 itemsbuf[i].misc1 = blue_potion_hearts;
21077 82 itemsbuf[i].misc2 = blue_potion_magic;
21078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
21079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
21080 82 break;
21081
21082 case iSword:
21083 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
21084 82 itemsbuf[i].misc1 = beam_hearts[0];
21085 82 itemsbuf[i].misc2 = beam_power[0];
21086 // It seems that item_flag1 was already added by reset_itembuf()...
21087 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
21088 82 break;
21089
21090 case iWSword:
21091 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
21092 82 itemsbuf[i].misc1 = beam_hearts[1];
21093 82 itemsbuf[i].misc2 = beam_power[1];
21094 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
21095 82 break;
21096
21097 case iMSword:
21098 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
21099 82 itemsbuf[i].misc1 = beam_hearts[2];
21100 82 itemsbuf[i].misc2 = beam_power[2];
21101 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
21102 82 break;
21103
21104 case iXSword:
21105 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
21106 82 itemsbuf[i].misc1 = beam_hearts[3];
21107 82 itemsbuf[i].misc2 = beam_power[3];
21108 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
21109 82 break;
21110
21111 case iHookshot:
21112 82 itemsbuf[i].misc1 = hookshot_length;
21113 82 itemsbuf[i].misc2 = hookshot_links;
21114 82 break;
21115
21116 case iLongshot:
21117 82 itemsbuf[i].misc1 = longshot_length;
21118 82 itemsbuf[i].misc2 = longshot_links;
21119 82 break;
21120 }
21121 21074 }
21122
21123
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
21124 {
21125 //was new subscreen rule
21126 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
21127 22 set_qr(qr_FREEFORM,0);
21128 22 }
21129
21130
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
21131 {
21132 23 temp_zinit.start_dmap=0;
21133 23 }
21134
21135
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
21136 {
21137 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
21138 23 }
21139
21140
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
21141 {
21142 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
21143 temp_zinit.mcounter[crMONEY]=999;
21144 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
21145 }
21146
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
21147 {
21148 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
21149 6 temp_zinit.mcounter[crBOMBS] = 8;
21150 6 }
21151 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
21152 //time to ensure that we port all new values properly:
21153
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
21154 {
21155
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
21156 82 }
21157
21158
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
21159 {
21160
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
21161 {
21162 return qe_invalid;
21163 }
21164
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
21165 {
21166 return qe_invalid;
21167 }
21168
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21169 {
21170 return qe_invalid;
21171 }
21172
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21173 {
21174 return qe_invalid;
21175 }
21176 17 }
21177 else
21178 {
21179 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
21180 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
21181 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
21182 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
21183 }
21184
21185
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
21186 {
21187
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
21189 return qe_invalid;
21190
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
21192 return qe_invalid;
21193 17 }
21194
21195
21196
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
21197 {
21198
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
21199 {
21200 return qe_invalid;
21201 }
21202
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
21203 {
21204 return qe_invalid;
21205 }
21206
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
21207 {
21208 return qe_invalid;
21209 }
21210
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21211 {
21212 return qe_invalid;
21213 }
21214
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21215 {
21216 return qe_invalid;
21217 }
21218 17 }
21219 else
21220 {
21221 282 temp_zinit.dither_type = 0;
21222 282 temp_zinit.dither_arg = 0;
21223 282 temp_zinit.dither_percent = 20;
21224 282 temp_zinit.def_lightrad = 24;
21225 282 temp_zinit.transdark_percent = 0;
21226 }
21227
21228
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21229 {
21230
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21231 {
21232 return qe_invalid;
21233 }
21234 17 }
21235 else
21236 {
21237 282 temp_zinit.darkcol = BLACK;
21238 }
21239
21240
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21241 {
21242
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21243 {
21244 return qe_invalid;
21245 }
21246
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21247 {
21248 return qe_invalid;
21249 }
21250 17 }
21251
21252
21253
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21254 {
21255
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21256 {
21257 return qe_invalid;
21258 }
21259
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21260 {
21261 return qe_invalid;
21262 }
21263
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21264 {
21265 return qe_invalid;
21266 }
21267 17 }
21268 else
21269 {
21270 282 temp_zinit.heroSideswimUpStep = 150;
21271 282 temp_zinit.heroSideswimSideStep = 100;
21272 282 temp_zinit.heroSideswimDownStep = 75;
21273 }
21274
21275
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21276 {
21277
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21278 {
21279 return qe_invalid;
21280 }
21281 17 }
21282 else
21283 {
21284 282 temp_zinit.exitWaterJump = 0;
21285 }
21286
21287
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21288 {
21289
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21290 {
21291 return qe_invalid;
21292 }
21293 17 }
21294 else
21295 {
21296 282 temp_zinit.bunny_ltm = 0;
21297 }
21298
21299
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21300 {
21301
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21302 {
21303 return qe_invalid;
21304 }
21305 17 }
21306 else
21307 {
21308 282 temp_zinit.switchhookstyle = 1;
21309 }
21310
21311
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21312 {
21313
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21314 {
21315 return qe_invalid;
21316 }
21317 17 }
21318
21319 299 temp_zinit.clear_genscript();
21320
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21321 {
21322 12 word numgenscript = 0;
21323
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21324 return qe_invalid;
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21326 return qe_invalid;
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21328 {
21329 if(!p_getc(&tempbyte,f))
21330 return qe_invalid;
21331 if(!(tempbyte&2))
21332 continue;
21333 temp_zinit.gen_doscript.set(q, tempbyte&1);
21334 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21335 return qe_invalid;
21336 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21337 return qe_invalid;
21338 for(auto p = 0; p < 8; ++p)
21339 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21340 return qe_invalid;
21341 dword sz;
21342 if(!p_igetl(&sz,f))
21343 return qe_invalid;
21344 temp_zinit.gen_data[q].resize(sz);
21345 std::vector<int32_t> dummy;
21346 if(!p_getlvec(&dummy,f))
21347 return qe_invalid;
21348 temp_zinit.gen_data[q] = dummy;
21349 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21350 return qe_invalid;
21351 }
21352 12 }
21353
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21354 {
21355
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21356 return qe_invalid;
21357
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21358 return qe_invalid;
21359 6 }
21360
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21361 {
21362 uint32_t num_used_mapscr_data;
21363 if(!p_igetl(&num_used_mapscr_data,f))
21364 return qe_invalid;
21365 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21366 {
21367 uint32_t sz;
21368 if(!p_igetl(&sz,f))
21369 return qe_invalid;
21370 temp_zinit.screen_data[q].resize(sz);
21371 if(sz)
21372 {
21373 std::vector<int32_t> dummy;
21374 if(!p_getlvec(&dummy,f))
21375 return qe_invalid;
21376 temp_zinit.screen_data[q] = dummy;
21377 }
21378 }
21379 }
21380
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21381 if(!p_igetzf(&temp_zinit.shove_offset,f))
21382 return qe_invalid;
21383
21384 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21385 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21386
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21387 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21388
21389 299 return 0;
21390 299 }
21391 497 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21392 {
21393 497 zinitdata temp_zinit = {};
21394
21395
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21396
21397 int32_t dummy;
21398 497 word s_version=0;
21399 byte padding;
21400
21401
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if(Header->zelda_version > 0x192)
21402 {
21403
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
21404 return qe_invalid;
21405
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_INITDATA)
21406 return qe_version;
21407 474 FFCore.quest_format[vInitData] = s_version;
21408
21409
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!read_deprecated_section_cversion(f))
21410 return qe_invalid;
21411
21412 //section size
21413
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
21414 return qe_invalid;
21415 474 }
21416
21417
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 198 times.
497 if(s_version < 37)
21418 {
21419
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21420 return ret;
21421 299 }
21422 else
21423 {
21424 198 subscr_mode = ssdtMAX;
21425
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 198 times.
6534 for(int q = 0; q < MAXITEMS/8; ++q)
21426
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.items[q], f))
21427 return qe_invalid;
21428
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 42)
21429 {
21430
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 169 times.
86697 for(int q = 0; q < MAXLEVELS; ++q)
21431 {
21432
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 78336 times.
86528 if (s_version >= 44)
21433 {
21434
2/4
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78336 times.
78336 if(!p_igetw(&temp_zinit.litems[q], f))
21435 return qe_invalid;
21436 78336 }
21437 else
21438 {
21439
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8192 times.
8192 if(!p_getc(&padding, f))
21440 return qe_invalid;
21441 8192 temp_zinit.litems[q] = word(padding);
21442 }
21443 86528 }
21444 169 }
21445 else
21446 {
21447 byte tmp_map[MAXLEVELS/8];
21448 byte tmp_compass[MAXLEVELS/8];
21449 byte tmp_boss_key[MAXLEVELS/8];
21450 byte tmp_mcguffin[MAXLEVELS/8];
21451
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(int q = 0; q < MAXLEVELS/8; ++q)
21452 {
21453
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&tmp_map[q], f))
21454 return qe_invalid;
21455
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&tmp_compass[q], f))
21456 return qe_invalid;
21457
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&tmp_boss_key[q], f))
21458 return qe_invalid;
21459
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&tmp_mcguffin[q], f))
21460 return qe_invalid;
21461 1856 }
21462
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int q = 0; q < MAXLEVELS; ++q)
21463 {
21464
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21465
3/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 14828 times.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21466
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21467
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21468 14848 }
21469 }
21470
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbvec(&temp_zinit.level_keys, f))
21471 return qe_invalid;
21472 byte num_counters;
21473
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&num_counters,f))
21474 return qe_invalid;
21475
2/2
✓ Branch 0 taken 21186 times.
✓ Branch 1 taken 198 times.
21384 for(int q = 0; q < num_counters; ++q)
21476
2/4
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21186 times.
21186 if(!p_igetw(&temp_zinit.counter[q],f))
21477 return qe_invalid;
21478
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 21186 times.
21384 for(int q = 0; q < num_counters; ++q)
21479
2/4
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21186 times.
21186 if(!p_igetw(&temp_zinit.mcounter[q],f))
21480 return qe_invalid;
21481
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.bomb_ratio,f))
21482 return qe_invalid;
21483
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hcp,f))
21484 return qe_invalid;
21485
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21486 return qe_invalid;
21487
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_igetw(&temp_zinit.cont_heart,f))
21488 return qe_invalid;
21489
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hp_per_heart,f))
21490 return qe_invalid;
21491
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.magic_per_block,f))
21492 return qe_invalid;
21493
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21494 return qe_invalid;
21495
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21496 return qe_invalid;
21497
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.dither_type,f))
21498 return qe_invalid;
21499
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.dither_arg,f))
21500 return qe_invalid;
21501
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.dither_percent,f))
21502 return qe_invalid;
21503
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.def_lightrad,f))
21504 return qe_invalid;
21505
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.transdark_percent,f))
21506 return qe_invalid;
21507
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.darkcol,f))
21508 return qe_invalid;
21509
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21510 return qe_invalid;
21511
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21512 return qe_invalid;
21513
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21514 return qe_invalid;
21515
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21516 return qe_invalid;
21517
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21518 return qe_invalid;
21519
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21520 return qe_invalid;
21521
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21522 return qe_invalid;
21523
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_flags,f))
21524 return qe_invalid;
21525
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbitstr(&temp_zinit.flags,f))
21526 return qe_invalid;
21527
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.last_map,f))
21528 return qe_invalid;
21529
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.last_screen,f))
21530 return qe_invalid;
21531
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_x,f))
21532 return qe_invalid;
21533
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_y,f))
21534 return qe_invalid;
21535
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21536 return qe_invalid;
21537
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_speed,f))
21538 return qe_invalid;
21539
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.gravity,f))
21540 return qe_invalid;
21541
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.swimgravity,f))
21542 return qe_invalid;
21543
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.terminalv,f))
21544 return qe_invalid;
21545
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21546 return qe_invalid;
21547
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21548 return qe_invalid;
21549
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_div,f))
21550 return qe_invalid;
21551
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21552 return qe_invalid;
21553
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21554 return qe_invalid;
21555
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21556 return qe_invalid;
21557
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21558 return qe_invalid;
21559
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroStep,f))
21560 return qe_invalid;
21561
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21562 return qe_invalid;
21563
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21564 return qe_invalid;
21565
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21566 return qe_invalid;
21567
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.start_dmap,f))
21568 return qe_invalid;
21569
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21570 return qe_invalid;
21571
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.switchhookstyle,f))
21572 return qe_invalid;
21573
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.magicdrainrate,f))
21574 return qe_invalid;
21575
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetzf(&temp_zinit.shove_offset,f))
21576 return qe_invalid;
21577
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21578 return qe_invalid;
21579
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21580 return qe_invalid;
21581
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21582 return qe_invalid;
21583
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getbmap(&temp_zinit.gen_initd, f))
21584 return qe_invalid;
21585
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21586 return qe_invalid;
21587
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_data, f))
21588 return qe_invalid;
21589
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.screen_data, f))
21590 return qe_invalid;
21591
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (s_version >= 38)
21592 {
21593
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21594 return qe_invalid;
21595
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21596 return qe_invalid;
21597
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21598 return qe_invalid;
21599 198 }
21600
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 39)
21601
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetzf(&temp_zinit.air_drag, f))
21602 return qe_invalid;
21603
21604 // TODO: this first branch can likely be removed, as it only fixes an issues
21605 // that existed for a handful of temporary z3 builds (and active users of that
21606 // fork would have been updating often, beyond s_version 40).
21607
3/4
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 169 times.
198 if (Header->is_z3 && s_version == 40)
21608 {
21609 if(!p_getc(&temp_zinit.region_mapping, f))
21610 return qe_invalid;
21611 }
21612 else
21613 {
21614
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 40)
21615 {
21616
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21617 return qe_invalid;
21618
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetw(&temp_zinit.light_wave_size, f))
21619 return qe_invalid;
21620 169 }
21621
21622
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 41)
21623 {
21624
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_getc(&temp_zinit.region_mapping, f))
21625 return qe_invalid;
21626 169 }
21627 }
21628
21629
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 163 times.
198 if(s_version >= 43)
21630
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 163 times.
41891 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21631
2/4
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41728 times.
✗ Branch 3 not taken.
41728 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21632 163 return qe_invalid;
21633
21634
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 45 times.
198 if(s_version >= 44)
21635
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21636 return qe_invalid;
21637
21638
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 45 times.
198 if (s_version >= 45)
21639 {
21640
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21641 return qe_invalid;
21642
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21643 return qe_invalid;
21644
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21645 return qe_invalid;
21646
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21647 return qe_invalid;
21648 153 }
21649
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 153 times.
198 if(s_version >= 46)
21650 {
21651
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 153 times.
918 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21652
2/4
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
765 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21653 return qe_invalid;
21654 153 }
21655 }
21656
21657
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 344 times.
497 if(s_version < 46)
21658 {
21659 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21660 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21661 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21662 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21663 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21664 344 }
21665
21666
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if (should_skip)
21667 return 0;
21668
21669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(loading_tileset_flags & TILESET_CLEARMAPS)
21670 {
21671 temp_zinit.last_map = 0;
21672 temp_zinit.last_screen = 0;
21673 temp_zinit.screen_data.clear();
21674 }
21675
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 temp_zinit.normalize();
21676
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 zinit = temp_zinit;
21677
21678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(zinit.heroAnimationStyle==las_zelda3slow)
21679 {
21680 hero_animation_speed=2;
21681 }
21682 else
21683 {
21684 497 hero_animation_speed=1;
21685 }
21686
21687 497 return 0;
21688 497 }
21689
21690 /*
21691 void setupitemdropsets()
21692 {
21693 for(int32_t i=0; i<isMAX; i++)
21694 {
21695 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21696 }
21697 }
21698 */
21699
21700 438 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21701 {
21702
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 23 times.
438 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21703
21704 dword dummy_dword;
21705 438 word item_drop_sets_to_read=0;
21706 item_drop_object tempitemdrop;
21707 438 word s_version=0;
21708
21709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438 times.
438 if (!should_skip)
21710
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21711 {
21712 112128 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21713 112566 }
21714
21715
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 23 times.
438 if(version > 0x192)
21716 {
21717 415 item_drop_sets_to_read=0;
21718
21719 //section version info
21720
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&s_version,f))
21721 {
21722 return qe_invalid;
21723 }
21724
21725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_ITEMDROPSETS)
21726 return qe_version;
21727
21728 415 FFCore.quest_format[vItemDropsets] = s_version;
21729
21730
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
21731 {
21732 return qe_invalid;
21733 }
21734
21735 //section size
21736
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy_dword,f))
21737 {
21738 return qe_invalid;
21739 }
21740
21741 //finally... section data
21742
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&item_drop_sets_to_read,f))
21743 {
21744 return qe_invalid;
21745 }
21746
21747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21748 {
21749 return qe_invalid;
21750 }
21751 415 }
21752 else
21753 {
21754 23 init_item_drop_sets();
21755 }
21756
21757
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 415 times.
438 if(s_version>=1)
21758 {
21759
2/2
✓ Branch 0 taken 6388 times.
✓ Branch 1 taken 415 times.
6803 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21760 {
21761
1/2
✓ Branch 0 taken 6388 times.
✗ Branch 1 not taken.
6388 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21762 {
21763 return qe_invalid;
21764 }
21765
21766
2/2
✓ Branch 0 taken 63880 times.
✓ Branch 1 taken 6388 times.
70268 for(int32_t j=0; j<10; ++j)
21767 {
21768
1/2
✓ Branch 0 taken 63880 times.
✗ Branch 1 not taken.
63880 if(!p_igetw(&tempitemdrop.item[j],f))
21769 {
21770 return qe_invalid;
21771 }
21772 63880 }
21773
21774
2/2
✓ Branch 0 taken 70268 times.
✓ Branch 1 taken 6388 times.
76656 for(int32_t j=0; j<11; ++j)
21775 {
21776
1/2
✓ Branch 0 taken 70268 times.
✗ Branch 1 not taken.
70268 if(!p_igetw(&tempitemdrop.chance[j],f))
21777 {
21778 return qe_invalid;
21779 }
21780 70268 }
21781
21782 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21783 // overrides the quest's set #12.
21784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6388 if(s_version<2 && i==12)
21785 continue;
21786
21787 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21788
1/4
✓ Branch 0 taken 6388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6388 if(s_version<2) for(int32_t j=0; j<10; ++j)
21789 {
21790 int32_t it = tempitemdrop.item[j];
21791
21792 if((itemsbuf[it].type == itype_rupee
21793 && ((itemsbuf[it].amount)&0xFFF) == 10)
21794 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21795 {
21796 tempitemdrop.chance[j+1]=0;
21797 }
21798 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21799 {
21800 tempitemdrop.chance[j+1]=0;
21801 }
21802
21803 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21804 if(itemsbuf[it].type == itype_misc)
21805 {
21806 // If a non-gameplay item was selected, then item drop was aborted.
21807 // Reflect this by increasing the 'Nothing' chance accordingly.
21808 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21809 tempitemdrop.chance[j+1]=0;
21810 }
21811 }
21812
21813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6388 times.
6388 if (!should_skip)
21814 6388 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21815 6388 }
21816 415 }
21817
21818 438 return 0;
21819 438 }
21820
21821 415 int32_t readfavorites(PACKFILE *f, int32_t)
21822 {
21823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21824
21825 int32_t temp_num;
21826 dword dummy_dword;
21827 word num_favorite_combos;
21828 word num_favorite_combo_aliases;
21829 415 word s_version=0;
21830
21831 //section version info
21832
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&s_version,f))
21833 {
21834 return qe_invalid;
21835 }
21836
21837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_FAVORITES)
21838 return qe_version;
21839
21840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (!should_skip)
21841 415 FFCore.quest_format[vFavourites] = s_version;
21842
21843
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
21844 {
21845 return qe_invalid;
21846 }
21847
21848 //section size
21849
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy_dword,f))
21850 {
21851 return qe_invalid;
21852 }
21853
21854 415 word per_row = FAVORITECOMBO_PER_ROW;
21855 415 word per_page = FAVORITECOMBO_PER_PAGE;
21856
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
415 if(s_version >= 3)
21857
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&per_row,f))
21858 return qe_invalid;
21859
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version >= 4)
21860
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&per_page,f))
21861 return qe_invalid;
21862 //finally... section data
21863
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&num_favorite_combos,f))
21864 {
21865 return qe_invalid;
21866 }
21867
21868 //Hack; port old favorite combos
21869
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
415 if(s_version < 3 && num_favorite_combos == 100)
21870 211 per_row = 13;
21871
21872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (!should_skip)
21873
2/2
✓ Branch 0 taken 522900 times.
✓ Branch 1 taken 415 times.
523315 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21874 523315 favorite_combos[q] = -1;
21875 415 byte favtype = 0;
21876
2/2
✓ Branch 0 taken 28021 times.
✓ Branch 1 taken 415 times.
28436 for(int32_t i=0; i<num_favorite_combos; i++)
21877 {
21878
2/2
✓ Branch 0 taken 6915 times.
✓ Branch 1 taken 21106 times.
28021 if (s_version >= 4)
21879 {
21880
1/2
✓ Branch 0 taken 6915 times.
✗ Branch 1 not taken.
6915 if (!p_getc(&favtype, f))
21881 {
21882 return qe_invalid;
21883 }
21884 6915 }
21885 else
21886 21106 favtype = 0;
21887
1/2
✓ Branch 0 taken 28021 times.
✗ Branch 1 not taken.
28021 if(!p_igetl(&temp_num,f))
21888 {
21889 return qe_invalid;
21890 }
21891
21892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28021 times.
28021 if (should_skip)
21893 continue;
21894
21895
2/2
✓ Branch 0 taken 6915 times.
✓ Branch 1 taken 21106 times.
28021 if(per_row == FAVORITECOMBO_PER_ROW)
21896 {
21897 6915 favorite_combos[i] = temp_num;
21898 6915 favorite_combo_modes[i] = favtype;
21899 6915 }
21900 else
21901 {
21902 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21903 21106 favorite_combos[new_i]=temp_num;
21904 21106 favorite_combo_modes[new_i] = favtype;
21905 }
21906 28021 }
21907
21908 // Discard the separate favorite aliases list from previous versions
21909
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 217 times.
415 if(s_version<4)
21910 {
21911
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21912 {
21913 return qe_invalid;
21914 }
21915
21916
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21917 {
21918
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21919 {
21920 return qe_invalid;
21921 }
21922 21100 }
21923 217 }
21924
21925 415 word max_combo_cols = 0;
21926 415 word max_mappages = 0;
21927
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
415 if(s_version >= 2)
21928 {
21929
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&max_combo_cols,f))
21930 return qe_invalid;
21931 204 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21932
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int q = 0; q < max_combo_cols; ++q)
21933 {
21934
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp,f))
21935 return qe_invalid;
21936
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp2,f))
21937 return qe_invalid;
21938
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp3,f))
21939 return qe_invalid;
21940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(q < MAX_COMBO_COLS)
21941 {
21942 816 First[q] = tmp;
21943 816 combo_alistpos[q] = tmp2;
21944 816 combo_pool_listpos[q] = tmp3;
21945 816 }
21946 816 }
21947
21948
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&max_mappages,f))
21949 return qe_invalid;
21950
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 204 times.
2040 for(int q = 0; q < max_mappages; ++q)
21951 {
21952
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(!p_igetl(&tmp,f))
21953 return qe_invalid;
21954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 if(!p_igetl(&tmp2,f))
21955 return qe_invalid;
21956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 if(q < MAX_MAPPAGE_BTNS)
21957 {
21958 1836 map_page[q].map = tmp;
21959 1836 map_page[q].screen = tmp2;
21960 1836 }
21961 1836 }
21962 204 }
21963
21964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (should_skip)
21965 return 0;
21966
21967
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 415 times.
1259 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21968 {
21969 844 First[q] = 0;
21970 844 combo_alistpos[q] = 0;
21971 844 combo_pool_listpos[q] = 0;
21972 844 }
21973
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 415 times.
2314 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21974 {
21975 1899 map_page[q].map = 0;
21976 1899 map_page[q].screen = 0;
21977 1899 }
21978
21979 415 return 0;
21980 415 }
21981
21982 /*
21983 switch (ret) {
21984 case 0:
21985 break;
21986
21987 case qe_invalid:
21988 goto invalid;
21989 break;
21990 default:
21991 pack_fclose(f);
21992 if(!oldquest)
21993 delete_file(tmpfilename);
21994 return ret;
21995 break;
21996 }
21997 */
21998
21999 const char *skip_text[skip_max]=
22000 {
22001 "skip_header", "skip_rules", "skip_strings", "skip_misc",
22002 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
22003 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
22004 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
22005 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
22006 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
22007 "skip_favorites"
22008 };
22009
22010
22011 void port250QuestRules(){
22012
22013 portCandleRules(); //Candle
22014 portBombRules();
22015
22016 }
22017
22018 void portCandleRules()
22019 {
22020 bool hurtshero = get_qr(qr_FIREPROOFHERO);
22021 //itemdata itemsbuf;
22022 for ( int32_t q = 0; q < MAXITEMS; q++ )
22023 {
22024 if ( itemsbuf[q].type == itype_candle )
22025 {
22026 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
22027 else itemsbuf[q].flags &= ~ item_flag2;
22028 }
22029 }
22030 }
22031
22032 void portBombRules()
22033 {
22034 bool hurtshero = get_qr(qr_OUCHBOMBS);
22035 //itemdata itemsbuf;
22036 for ( int32_t q = 0; q < MAXITEMS; q++ )
22037 {
22038 if ( itemsbuf[q].type == itype_bomb )
22039 {
22040 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
22041 else itemsbuf[q].flags &= ~ item_flag2;
22042 }
22043 }
22044 }
22045
22046 19269 static int section_id_to_enum(int id)
22047 {
22048
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 832 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 832 times.
✓ Branch 5 taken 832 times.
✓ Branch 6 taken 749 times.
✓ Branch 7 taken 832 times.
✓ Branch 8 taken 832 times.
✓ Branch 9 taken 832 times.
✓ Branch 10 taken 832 times.
✓ Branch 11 taken 832 times.
✓ Branch 12 taken 832 times.
✓ Branch 13 taken 749 times.
✓ Branch 14 taken 749 times.
✓ Branch 15 taken 832 times.
✓ Branch 16 taken 832 times.
✓ Branch 17 taken 773 times.
✓ Branch 18 taken 749 times.
✓ Branch 19 taken 749 times.
✓ Branch 20 taken 749 times.
✓ Branch 21 taken 832 times.
✓ Branch 22 taken 832 times.
✓ Branch 23 taken 773 times.
✓ Branch 24 taken 749 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
19269 switch (id)
22049 {
22050 case ID_HEADER: return skip_header;
22051 832 case ID_RULES: return skip_rules;
22052 832 case ID_STRINGS: return skip_strings;
22053 832 case ID_MISC: return skip_misc;
22054 832 case ID_TILES: return skip_tiles;
22055 832 case ID_COMBOS: return skip_combos;
22056 749 case ID_COMBOALIASES: return skip_comboaliases;
22057 832 case ID_CSETS: return skip_csets;
22058 832 case ID_MAPS: return skip_maps;
22059 832 case ID_DMAPS: return skip_dmaps;
22060 832 case ID_DOORS: return skip_doors;
22061 832 case ID_ITEMS: return skip_items;
22062 832 case ID_WEAPONS: return skip_weapons;
22063 749 case ID_COLORS: return skip_colors;
22064 749 case ID_ICONS: return skip_icons;
22065 832 case ID_INITDATA: return skip_initdata;
22066 832 case ID_GUYS: return skip_guys;
22067 773 case ID_HEROSPRITES: return skip_herosprites;
22068 749 case ID_SUBSCREEN: return skip_subscreens;
22069 749 case ID_FFSCRIPT: return skip_ffscript;
22070 749 case ID_SFX: return skip_sfx;
22071 832 case ID_MIDIS: return skip_midis;
22072 832 case ID_CHEATS: return skip_cheats;
22073 773 case ID_ITEMDROPSETS: return skip_itemdropsets;
22074 749 case ID_FAVORITES: return skip_favorites;
22075 case ID_ZINFO: return skip_zinfo;
22076 }
22077
22078 return -1;
22079 19269 }
22080
22081 18861 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
22082 {
22083 18861 int section_enum = section_id_to_enum(section_id);
22084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18861 times.
18861 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22085
2/2
✓ Branch 0 taken 7014 times.
✓ Branch 1 taken 11847 times.
18861 if (skip)
22086 {
22087 word s_version;
22088
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!p_igetw(&s_version,f))
22089 {
22090 return qe_invalid;
22091 }
22092
22093
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!read_deprecated_section_cversion(f))
22094 {
22095 return qe_invalid;
22096 }
22097
22098
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
7014 if (section_id == ID_RULES && s_version > 16)
22099 {
22100 dword dummy;
22101 if (!p_igetl(&dummy,f))
22102 {
22103 return qe_invalid;
22104 }
22105 }
22106
22107
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
7014 if (section_id == ID_FFSCRIPT && s_version >= 18)
22108 {
22109 word dummy;
22110 if (!p_igetw(&dummy,f))
22111 {
22112 return qe_invalid;
22113 }
22114 }
22115
22116 dword section_length;
22117
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!p_igetl(&section_length,f))
22118 {
22119 return qe_invalid;
22120 }
22121
22122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7014 times.
7014 if (pack_fseek(f, section_length))
22123 {
22124 return qe_invalid;
22125 }
22126
22127
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
7014 if (!pack_feof(f))
22128 {
22129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6680 times.
6680 if (!p_mgetl(&section_id,f))
22130 {
22131 return qe_invalid;
22132 }
22133 6680 }
22134
22135 7014 return qe_cancel;
22136 }
22137
22138 11847 return qe_OK;
22139 18861 }
22140
22141 // TODO: this was copied from zc/zasm_utils.cpp
22142 283 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
22143 {
22144 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
22145
22146 283 std::vector<zasm_script*> scripts;
22147
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 scripts.reserve(zasm_scripts.size());
22148
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 305182 times.
305465 for (auto& script : zasm_scripts)
22149
2/2
✓ Branch 0 taken 296700 times.
✓ Branch 1 taken 8482 times.
305182 if (script->valid())
22150
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
22151
22152
2/4
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
283 std::for_each(scripts.begin(), scripts.end(), fn);
22153 283 }
22154
22155 497 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
22156 {
22157 // 2.55.9 or newer?
22158
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 327 times.
497 if (header.compareVer(2, 55, 9) >= 0)
22159 170 return false; // defer to whatever was set
22160
22161 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
22162
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 277 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 277 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 277 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 277 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 277 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 289 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
327 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
22163 38 return true;
22164
22165 // Quests prior to 2.55.9 with a scripted subscreen?
22166
2/2
✓ Branch 0 taken 146435 times.
✓ Branch 1 taken 286 times.
146721 for (int i = 0; i < MAXDMAPS; i++)
22167 {
22168 146435 int script = DMaps[i].active_sub_script;
22169
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 146432 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
146435 if (script && dmapscripts[script] && dmapscripts[script]->valid())
22170 3 return true;
22171 146432 }
22172
22173 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
22174
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 std::string title = header.title;
22175
3/4
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 283 times.
286 if (title == "Yuurand: Tales of the Labyrinth")
22176 3 return true;
22177
22178 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
22179 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
22180 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
22181 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
22182 283 bool found = false;
22183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
8765 _zasm_for_every_script([&](auto script){
22184
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
22185
22186
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
22187 {
22188
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
22189
22190 3316130 int value = instr.arg2;
22191
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
22192 {
22193 30 found = true;
22194 30 break;
22195 }
22196 }
22197 8482 });
22198
22199 283 return found;
22200 497 }
22201
22202 static int32_t prev_quest_format[versiontypesLAST];
22203 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
22204 static byte prev_extra_rules[EXTRARULES_SIZE];
22205 static byte prev_midi_flags[MIDIFLAGS_SIZE];
22206 static word prev_map_count;
22207
22208 // When skipping any section, we are loading a qst file just to poke at a couple things.
22209 // We should not mutate important globals in that case.
22210 // We should also restore these globals when loading a qst fails.
22211 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
22212 // (see load_imagebuf).
22213 832 static void store_prev_qstload_global_state()
22214 {
22215 832 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
22216 832 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
22217 832 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
22218 832 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22219 832 prev_map_count = map_count;
22220 832 }
22221
22222 335 static void restore_prev_qstload_global_state()
22223 {
22224 335 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22225 335 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22226 335 unpack_qrs();
22227 335 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
22228 335 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22229 335 map_count = prev_map_count;
22230 335 }
22231
22232 //Internal function for loadquest wrapper
22233 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22234 832 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22235 {
22236 832 DMapEditorLastMaptileUsed = 0;
22237 832 combosread=false;
22238 832 mapsread=false;
22239 832 fixffcs=false;
22240
22241 832 store_prev_qstload_global_state();
22242
22243 832 bool skipping_any = false;
22244
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 832 times.
4160 for (int i = 0; i < 4; i++)
22245 3328 skipping_any |= skip_flags[i] ? true : false;
22246
22247 832 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22248
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22249 {
22250 set_bit(skip_flags, skip_ffscript, 1);
22251 setZScriptVersion(V_FFSCRIPT);
22252 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22253 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22254 do_clear_scripts = true;
22255 }
22256
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(loading_tileset_flags & TILESET_CLEARMAPS)
22257 {
22258 set_bit(skip_flags, skip_maps, 1);
22259 }
22260
22261 char tmpfilename[L_tmpnam];
22262 832 temp_name(tmpfilename);
22263 832 bool catchup=false;
22264 byte tempbyte;
22265
22266 // oldquest flag is set when an unencrypted qst file is suspected.
22267 832 bool oldquest = false;
22268 832 int32_t open_error=0;
22269 832 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22270
22271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!f)
22272 {
22273 ASSERT(open_error != 0);
22274 return open_error;
22275 }
22276
22277 832 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22278 832 memset(extra_rules, 0, EXTRARULES_SIZE);
22279 832 unpack_qrs();
22280
22281
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if (!get_bit(skip_flags, skip_maps))
22282 497 Regions = {};
22283
22284
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if(do_clear_scripts)
22285 {
22286 497 zScript.clear();
22287 497 globalmap.clear();
22288 497 genericmap.clear();
22289 497 ffcmap.clear();
22290 497 itemmap.clear();
22291 497 npcmap.clear();
22292 497 ewpnmap.clear();
22293 497 lwpnmap.clear();
22294 497 playermap.clear();
22295 497 dmapmap.clear();
22296 497 screenmap.clear();
22297 497 itemspritemap.clear();
22298 497 comboscriptmap.clear();
22299 497 subscreenmap.clear();
22300
22301
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22302 {
22303 253967 ffcmap[i].clear();
22304 253967 }
22305
22306 497 globalmap[0].slotname = "Slot 1:";
22307 497 globalmap[0].scriptname = "~Init";
22308 497 globalmap[0].update();
22309
22310
2/2
✓ Branch 0 taken 3479 times.
✓ Branch 1 taken 497 times.
3976 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22311 {
22312 3479 globalmap[i].clear();
22313 3479 }
22314
22315
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22316 {
22317 126735 itemmap[i].clear();
22318 126735 }
22319
22320 //new script types -- prevent carrying over to a quest that you load after reading them
22321 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22322
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22323 {
22324 126735 npcmap[i].clear();
22325 126735 }
22326
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22327 {
22328 126735 lwpnmap[i].clear();
22329 126735 }
22330
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22331 {
22332 126735 ewpnmap[i].clear();
22333 126735 }
22334
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 497 times.
2485 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22335 {
22336 1988 playermap[i].clear();
22337 1988 }
22338
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22339 {
22340 126735 dmapmap[i].clear();
22341 126735 }
22342
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22343 {
22344 126735 screenmap[i].clear();
22345 126735 }
22346
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22347 {
22348 126735 itemspritemap[i].clear();
22349 126735 }
22350
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22351 {
22352 253967 comboscriptmap[i].clear();
22353 253967 }
22354
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22355 {
22356 253967 genericmap[i].clear();
22357 253967 }
22358
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22359 {
22360 126735 subscreenmap[i].clear();
22361 126735 }
22362
22363 497 reset_scripts();
22364 497 }
22365
22366 832 zquestheader tempheader{};
22367
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tempheader.filename = filename;
22368
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 zinfo tempzi;
22369
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tempzi.clear();
22370 832 load_tmp_zi = &tempzi;
22371
22372 char zinfofilename[2048];
22373
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 replace_extension(zinfofilename, filename, "zinfo", 2047);
22374 832 int32_t ret=0;
22375
22376 //header
22377
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("Reading Header...");
22378
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 ret=readheader(f, &tempheader, printmetadata);
22379
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
832 checkstatus(ret);
22380
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("okay.");
22381
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_eol();
22382
22383
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
832 if(read_zinfo)
22384 {
22385
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_out("Reading ZInfo - ");
22386
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 box_out(read_ext_zinfo ? "External..." : "Internal...");
22387
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 212 times.
215 if(read_ext_zinfo)
22388 {
22389
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22390
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22392
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22393 3 }
22394 else
22395 {
22396
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 ret=readzinfo(f, tempzi, tempheader);
22397
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
212 checkstatus(ret);
22398 }
22399
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_out("okay.");
22400
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_eol();
22401 215 }
22402
22403
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(tempheader.zelda_version>=0x193)
22404 {
22405 dword section_id;
22406
22407 //section id
22408
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_mgetl(&section_id,f))
22409 {
22410 goto invalid;
22411 }
22412
22413 808 std::set<dword> seen_sections;
22414
22415
3/4
✓ Branch 0 taken 19669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18861 times.
✓ Branch 3 taken 808 times.
19669 while(!pack_feof(f))
22416 {
22417
2/4
✓ Branch 0 taken 18861 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18861 times.
✗ Branch 3 not taken.
18861 if (seen_sections.contains(section_id))
22418 goto invalid;
22419
1/2
✓ Branch 0 taken 18861 times.
✗ Branch 1 not taken.
18861 seen_sections.insert(section_id);
22420
22421
3/4
✓ Branch 0 taken 18861 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11847 times.
✓ Branch 3 taken 7014 times.
18861 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22422 {
22423
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (retval == qe_cancel)
22424 7014 continue;
22425 checkstatus(retval);
22426 }
22427
22428
24/25
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 808 times.
✓ Branch 4 taken 474 times.
✓ Branch 5 taken 415 times.
✓ Branch 6 taken 808 times.
✓ Branch 7 taken 474 times.
✓ Branch 8 taken 474 times.
✓ Branch 9 taken 474 times.
✓ Branch 10 taken 474 times.
✓ Branch 11 taken 474 times.
✓ Branch 12 taken 415 times.
✓ Branch 13 taken 415 times.
✓ Branch 14 taken 474 times.
✓ Branch 15 taken 474 times.
✓ Branch 16 taken 415 times.
✓ Branch 17 taken 415 times.
✓ Branch 18 taken 415 times.
✓ Branch 19 taken 415 times.
✓ Branch 20 taken 474 times.
✓ Branch 21 taken 474 times.
✓ Branch 22 taken 415 times.
✓ Branch 23 taken 415 times.
✗ Branch 24 not taken.
11847 switch(section_id)
22429 {
22430 case ID_RULES:
22431
22432 //rules
22433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22434 {
22435 box_out("found.");
22436 box_eol();
22437 catchup=false;
22438 }
22439
22440
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Rules...");
22441
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readrules(f, &tempheader);
22442
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22443
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22444
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22445 474 break;
22446
22447 case ID_STRINGS:
22448
22449 //strings
22450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22451 {
22452 box_out("found.");
22453 box_eol();
22454 catchup=false;
22455 }
22456
22457
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Strings...");
22458
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readstrings(f, &tempheader);
22459
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22460
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22461
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22462 474 break;
22463
22464 case ID_MISC:
22465
22466 //misc data
22467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22468 {
22469 box_out("found.");
22470 box_eol();
22471 catchup=false;
22472 }
22473
22474
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Misc. Data...");
22475
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readmisc(f, &tempheader, Misc);
22476
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22477
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22478
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22479 808 break;
22480
22481 case ID_TILES:
22482
22483 //tiles
22484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22485 {
22486 box_out("found.");
22487 box_eol();
22488 catchup=false;
22489 }
22490
22491
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Tiles...");
22492
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22493
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22494
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22495
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22496 808 break;
22497
22498 case ID_COMBOS:
22499
22500 //combos
22501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22502 {
22503 box_out("found.");
22504 box_eol();
22505 catchup=false;
22506 }
22507
22508
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Combos...");
22509
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22510 474 combosread=true;
22511
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22512
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22513
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22514 474 break;
22515
22516 case ID_COMBOALIASES:
22517
22518 //combo aliases
22519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22520 {
22521 box_out("found.");
22522 box_eol();
22523 catchup=false;
22524 }
22525
22526
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Combo Aliases...");
22527
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22528
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22529
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22530
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22531 415 break;
22532
22533 case ID_CSETS:
22534
22535 //color data
22536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22537 {
22538 box_out("found.");
22539 box_eol();
22540 catchup=false;
22541 }
22542
22543
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Color Data...");
22544
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22545
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22546
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22547
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22548 808 break;
22549
22550 case ID_MAPS:
22551
22552 //maps
22553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22554 {
22555 box_out("found.");
22556 box_eol();
22557 catchup=false;
22558 }
22559
22560
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Maps...");
22561
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readmaps(f, &tempheader);
22562 474 mapsread=true;
22563
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22564
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22565
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22566 474 break;
22567
22568 case ID_DMAPS:
22569
22570 //dmaps
22571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22572 {
22573 box_out("found.");
22574 box_eol();
22575 catchup=false;
22576 }
22577
22578
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading DMaps...");
22579
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22580
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22581
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22582
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22583 474 break;
22584
22585 case ID_DOORS:
22586
22587 //door combo sets
22588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22589 {
22590 box_out("found.");
22591 box_eol();
22592 catchup=false;
22593 }
22594
22595
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Doors...");
22596
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readdoorcombosets(f, &tempheader);
22597
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22598
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22599
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22600 474 break;
22601
22602 case ID_ITEMS:
22603
22604 //items
22605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22606 {
22607 box_out("found.");
22608 box_eol();
22609 catchup=false;
22610 }
22611
22612
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Items...");
22613
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22614
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22615
22616
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22617
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22618 474 break;
22619
22620 case ID_WEAPONS:
22621
22622 //weapons
22623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22624 {
22625 box_out("found.");
22626 box_eol();
22627 catchup=false;
22628 }
22629
22630
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Weapons...");
22631
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readweapons(f, &tempheader);
22632
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22633
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22634
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22635 474 break;
22636
22637 case ID_COLORS:
22638
22639 //misc. colors
22640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22641 {
22642 box_out("found.");
22643 box_eol();
22644 catchup=false;
22645 }
22646
22647
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Misc. Colors...");
22648
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readmisccolors(f, &tempheader, Misc);
22649
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22650
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22651
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22652 415 break;
22653
22654 case ID_ICONS:
22655
22656 //game icons
22657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22658 {
22659 box_out("found.");
22660 box_eol();
22661 catchup=false;
22662 }
22663
22664
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Game Icons...");
22665
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readgameicons(f, &tempheader, Misc);
22666
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22667
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22668
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22669 415 break;
22670
22671 case ID_INITDATA:
22672
22673 //initialization data
22674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22675 {
22676 box_out("found.");
22677 box_eol();
22678 catchup=false;
22679 }
22680
22681
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Init. Data...");
22682
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readinitdata(f, &tempheader);
22683
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22684
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22685
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22686
22687
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!get_bit(skip_flags, skip_subscreens))
22688 {
22689
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 380 times.
474 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22690 {
22691
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22692
22693
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22694 {
22695 48128 int32_t type=DMaps[i].type&dmfTYPE;
22696
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22697 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22698 48128 }
22699 94 }
22700 474 }
22701
22702
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!get_bit(skip_flags, skip_sfx))
22703 {
22704 474 setupsfx();
22705 474 }
22706
22707
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!get_bit(skip_flags, skip_itemdropsets))
22708 {
22709
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 init_item_drop_sets();
22710 474 }
22711
22712
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!get_bit(skip_flags, skip_favorites))
22713 {
22714 474 init_favorites();
22715 474 }
22716
22717 474 break;
22718
22719 case ID_GUYS:
22720
22721 //guys
22722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22723 {
22724 box_out("found.");
22725 box_eol();
22726 catchup=false;
22727 }
22728
22729
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Custom Guy Data...");
22730
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readguys(f, &tempheader);
22731
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22732
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22733
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22734 474 break;
22735
22736 case ID_HEROSPRITES:
22737
22738 //hero sprites
22739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22740 {
22741 box_out("found.");
22742 box_eol();
22743 catchup=false;
22744 }
22745
22746
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Custom Hero Sprite Data...");
22747
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readherosprites(f, &tempheader);
22748
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22749
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22750
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22751 415 break;
22752
22753 case ID_SUBSCREEN:
22754
22755 //custom subscreens
22756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22757 {
22758 box_out("found.");
22759 box_eol();
22760 catchup=false;
22761 }
22762
22763
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Custom Subscreen Data...");
22764
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readsubscreens(f);
22765
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22766
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22767
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22768 415 break;
22769
22770 case ID_FFSCRIPT:
22771
22772 //Freeform combo scripts
22773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22774 {
22775 box_out("found.");
22776 box_eol();
22777 catchup=false;
22778 }
22779
22780
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading FF Script Data...");
22781
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readffscript(f, &tempheader);
22782
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22783
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22784
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22785 415 break;
22786
22787 case ID_SFX:
22788
22789 //SFX data
22790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22791 {
22792 box_out("found.");
22793 box_eol();
22794 catchup=false;
22795 }
22796
22797
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading SFX Data...");
22798
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readsfx(f, &tempheader);
22799
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22800
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22801
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22802 415 break;
22803
22804 case ID_MIDIS:
22805
22806 //midis
22807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22808 {
22809 box_out("found.");
22810 box_eol();
22811 catchup=false;
22812 }
22813
22814
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading MIDIs...");
22815
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readmidis(f, &tempheader, tunes);
22816
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22817
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22818
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22819 474 break;
22820
22821 case ID_CHEATS:
22822
22823 //cheat codes
22824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22825 {
22826 box_out("found.");
22827 box_eol();
22828 catchup=false;
22829 }
22830
22831
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Cheat Codes...");
22832
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readcheatcodes(f, &tempheader);
22833
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22834
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22835
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22836 474 break;
22837
22838 case ID_ITEMDROPSETS:
22839
22840 //item drop sets
22841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22842 {
22843 box_out("found.");
22844 box_eol();
22845 catchup=false;
22846 }
22847
22848
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Item Drop Sets...");
22849
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readitemdropsets(f, tempheader.zelda_version);
22850
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22851
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22852
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22853 415 break;
22854
22855 case ID_FAVORITES:
22856
22857 //favorite combos and combo aliases
22858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22859 {
22860 box_out("found.");
22861 box_eol();
22862 catchup=false;
22863 }
22864
22865
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Favorite Combos...");
22866
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readfavorites(f, tempheader.zelda_version);
22867
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22868
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22869
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22870 415 break;
22871
22872 default:
22873 if(!catchup)
22874 {
22875 box_out("Bad token! Searching...");
22876 box_eol();
22877 }
22878
22879 catchup=true;
22880 break;
22881 }
22882
22883
22884
1/2
✓ Branch 0 taken 11847 times.
✗ Branch 1 not taken.
11847 if(catchup)
22885 {
22886 //section id
22887 section_id=(section_id<<8);
22888
22889 if(!p_getc(&tempbyte,f))
22890 {
22891 goto invalid;
22892 }
22893
22894 section_id+=tempbyte;
22895 }
22896
22897 else
22898 {
22899 //section id
22900
3/4
✓ Branch 0 taken 11847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11373 times.
✓ Branch 3 taken 474 times.
11847 if(!pack_feof(f))
22901 {
22902
2/4
✓ Branch 0 taken 11373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11373 times.
✗ Branch 3 not taken.
11373 if(!p_mgetl(&section_id,f))
22903 {
22904 goto invalid;
22905 }
22906 11373 }
22907 }
22908 }
22909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 }
22910 else
22911 {
22912
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22913
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22914
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22915
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22916
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22917
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22918
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22919
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22920
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22921
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22922
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22923
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22924
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22925
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "MIDIs", ID_MIDIS, [&](){ return readmidis(f, &tempheader, tunes); }},
22926
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22927
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22928
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22929
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22930 };
22931
22932 24 legacy_skip_flags = skip_flags;
22933
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22934 {
22935
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22936
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22937
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22938 {
22939 // Nothing to read.
22940
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22941 1 continue;
22942
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22943 1 continue;
22944
22945 // Haven't looked at how to skip these, because we don't need to currently: the only
22946 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22947
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22948 1 continue;
22949
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22950 1 continue;
22951
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22952 1 continue;
22953
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22954 1 continue;
22955
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22956 1 continue;
22957 9 }
22958
22959 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22960 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22961 // read all the sections even if requested to skip some.
22962 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22963 // {
22964 // if (retval == qe_cancel)
22965 // continue;
22966 // checkstatus(retval);
22967 // }
22968
22969
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22970
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22971
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22972
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22973
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22974 }
22975 24 legacy_skip_flags = nullptr;
22976
22977
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22978 {
22979
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22980
22981
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22982 {
22983 11776 int32_t type=DMaps[i].type&dmfTYPE;
22984
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22985 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22986 11776 }
22987 23 }
22988
22989
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22990
22991
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22992 23 setupsfx();
22993
22994
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22995 23 init_favorites();
22996
22997
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22998
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22999
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
23000
23001
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 init_spritelists();
23002
23003 // check data
23004
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(f)
23005 {
23006
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 pack_fclose(f);
23007 832 }
23008
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 clear_quest_tmpfile();
23009
23010
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!oldquest)
23011 {
23012
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(exists(tmpfilename))
23013 {
23014 delete_file(tmpfilename);
23015 }
23016 832 }
23017
23018
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(fixffcs && combosread && mapsread)
23019 {
23020 for(int32_t i=0; i<map_count; i++)
23021 {
23022 for(int32_t j=0; j<MAPSCRS; j++)
23023 {
23024 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
23025 for(int32_t m=0; m<c; m++)
23026 {
23027 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
23028 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
23029 }
23030 }
23031 }
23032 }
23033
23034
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if (!get_bit(skip_flags, skip_rules))
23035 {
23036
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
23037
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
23038
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 423 times.
497 if (should_hide)
23039
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
23040
23041
3/4
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 328 times.
497 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
23042 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
23043 497 }
23044
23045
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 769 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
832 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
23046 {
23047
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
23048
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
23049 62 zinit.cont_heart=100;
23050 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
23051 62 }
23052
23053
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("Done.");
23054
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_eol();
23055
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_end(false);
23056
23057
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 334 times.
832 if(!get_bit(skip_flags, skip_header))
23058 {
23059
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 *Header = tempheader;
23060 498 }
23061
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if(!get_bit(skip_flags, skip_zinfo))
23062 {
23063
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 ZI.copyFrom(tempzi);
23064 497 }
23065
23066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(loading_tileset_flags & TILESET_CLEARMAPS)
23067 {
23068 TheMaps.clear();
23069 TheMaps.resize(MAPSCRS*1);
23070 map_count = 1;
23071 map_infos.clear();
23072 map_infos.resize(1);
23073 }
23074
23075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(loading_tileset_flags & TILESET_CLEARHEADER)
23076 {
23077 memset(Header->password, 0, sizeof(Header->password));
23078 memset(Header->minver, 0, sizeof(Header->minver));
23079 memset(Header->title, 0, sizeof(Header->title));
23080 memset(Header->author, 0, sizeof(Header->author));
23081 memset(Header->version, 0, sizeof(Header->version));
23082 Header->use_keyfile = 0;
23083 Header->dirty_password = false;
23084 cvs_MD5Context ctx;
23085 cvs_MD5Init(&ctx);
23086 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
23087 cvs_MD5Final(Header->pwd_hash, &ctx);
23088 }
23089
23090
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if (!get_bit(skip_flags, skip_maps))
23091 {
23092 // Not needed, so release its memory.
23093
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 old_combo_pages = {};
23094 497 }
23095
23096
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if (skipping_any)
23097
1/2
✓ Branch 0 taken 335 times.
✗ Branch 1 not taken.
335 restore_prev_qstload_global_state();
23098
23099 832 return qe_OK;
23100
23101 invalid:
23102 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
23103 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
23104 box_out("error.");
23105 box_eol();
23106 box_end(true);
23107
23108 pack_fclose(f);
23109
23110 if(!oldquest)
23111 {
23112 if(exists(tmpfilename))
23113 {
23114 delete_file(tmpfilename);
23115 }
23116 }
23117
23118 restore_prev_qstload_global_state();
23119
23120 return qe_invalid;
23121
23122 832 }
23123
23124 334 std::string get_last_loaded_qstpath()
23125 {
23126 334 return last_loaded_qstpath;
23127 }
23128
23129 832 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
23130 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
23131 bool report, byte qst_num, dword tilesetflags)
23132 {
23133 832 loading_tileset_flags = tilesetflags;
23134 832 const char* basename = get_filename(filename);
23135 832 zapp_reporting_add_breadcrumb("load_quest", basename);
23136 832 zapp_reporting_set_tag("qst.filename", basename);
23137
23138 832 last_loaded_qstpath = filename;
23139 832 loading_qst_name = filename;
23140 832 loading_qst_num = qst_num;
23141 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
23142 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
23143
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (!is_ci())
23144 loadquest_report = report;
23145
23146 832 auto start = std::chrono::steady_clock::now();
23147 832 zprint2("Loading qst: %s\n", filename);
23148 832 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
23149 832 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
23150 832 zprint2("Time to load qst: %d ms\n", load_ms);
23151
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (ret)
23152 zprint2("Error: %s\n", qst_error[ret]);
23153
23154
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(show_progress)
23155 {
23156 if(ret)
23157 {
23158 box_out("-- Error loading quest file! --");
23159 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
23160 box_end(true);
23161 }
23162 else box_end(false);
23163 }
23164
23165 832 load_tmp_zi = NULL;
23166 832 loading_qst_name = NULL;
23167 832 loadquest_report = false;
23168 832 loading_qst_num = 0;
23169
23170 832 zapp_reporting_set_tag("qst.author", Header->author);
23171 832 zapp_reporting_set_tag("qst.title", Header->title);
23172 832 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
23173
23174 832 return ret;
23175 }
23176